Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support array 'unfolding' syntax #10

Open
BraedonWooding opened this issue Jul 4, 2018 · 0 comments
Open

Support array 'unfolding' syntax #10

BraedonWooding opened this issue Jul 4, 2018 · 0 comments

Comments

@BraedonWooding
Copy link
Member

BraedonWooding commented Jul 4, 2018

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 ).

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

No branches or pull requests

1 participant