Skip to content

Suggestion: Add arrays of dynamic size #204

@klauso

Description

@klauso

The tuples and arrays as they are presented in Chapter 7 of the book are a little unsatisfactory in that their sizes are all known at compile-time and could all be stored on the stack instead of the heap.

My suggestion would be to add a new array creation expression "newArray(size, init)" where size is an integer-typed expression and init is a value with which all array elements get initialized (through a while loop). That would necessitate to generalize "collect" and "Allocate" in the intermediate languages to accept an expression/atom as the size argument instead of a fixed integer, but that would be easy.

It would be a simple extension that would convincingly drive home the message that we really need heap allocation, garbage collection, and all that jazz.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions