mun icon indicating copy to clipboard operation
mun copied to clipboard

Dynamically Sized Arrays v0.1

Open baszalmstra opened this issue 4 years ago • 1 comments

This is a tracking issue regarding the implementation of dynamically sized arrays.

This reflects the work that is required for an initial release of Mun with array support (arrays v0.1). This will allow the construction and use of arrays but will still miss a lot of essential features to make working with them easier.

Out of scope

Things that are out of scope for this initial v0.1 version:

  • Querying the length of an array
  • Resizing an array
  • Appending to an array

Required work

  • [x] Array types Mun must have support for array types so we can pass them around in code.

    • [x] Syntax of array types must be parsable
    • [x] The vscode grammar must be updated to support these types
    • [x] Code generation to handle array types
    • [x] ABI support for array types
    fn identity(arr: [int]) -> [int] { arr }
    
  • [ ] Array construction Enable the construction of arrays from mun code.

    let a = [1,2,3,4]
    
    • [x] Syntax support for array literals
    • [x] HIR support for array literals including type inferencing
    • [x] Runtime support for allocation of array literals
    • [x] Support arrays in the garbage collector
    • [ ] Support hot reloading of arrays.
    • [x] Use arrays through the runtime.
    • [x] Create arrays through the runtime.

    Open questions

    • What and how do we support the hot-reloading of arrays? Which operations are (not) allowed?
  • [x] Array indexing support.

    let a = arr[i]
    arr[i] = 3.0
    
    • [x] Syntax support for array indexing
    • [x] HIR support for array indexing including type inferencing
    • [x] Language server support for array indexing (proper completion in brackets)
    • [x] Code generation for array indexing

baszalmstra avatar May 08 '21 14:05 baszalmstra

I updated this issue to reflect all the work that I think is required for the first version. I dubbed this arrays v0.1 because it's still missing a lot of features. However, with the work specified above it should become possible to at least use them!

baszalmstra avatar May 14 '22 09:05 baszalmstra