Skip to content

Support array 'unfolding' syntax #10

Description

@BraedonWooding

For example in python you can use the * operator like x(*array) which translates to expanding the array as if it was a series of arguments i.e. the following;

arr = [1, 2, 3]
x(arr) # is just x( [1, 2, 3] )
x(*arr) # is x( 1, 2, 3 ) - note how the 'array' is gone

Since definitions don't allow multiple arguments due to their nature of being able to be typed i.e.
arr : []int = [1, 2, 3] should we be able to 'not type' them (thus allowing the values to not conform to the type UNTIL they are used in a function call) then later 'unfold' them i.e.

arr := [1, 2, 3, 5.0, true]
A.x = arr // error: not all types are the same
A.x = *arr // perfectly fine is just the same as A.x = 1, 2, 3, 5.0, true

Now the question is also what should the syntax be, I don't particularly like the * as it is too close to the pointer syntax in languages for my liking; I would prefer a more 'slice' based syntax i.e. arr[..]. This would fit the similar syntax of the proposed slices (#11 ).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions