Change dict syntax from {, ...}
to :{...}
#124
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change
{, 1:a 2:b }
:{ 1:a 2:b }
1 2 :{x y, 3:z} => :{1:x 2:y 3:z}
:{operator.name}
to:(operator.name)
Reason for change: Improved interaction between dict literals and the stack
Want to create a dict using the top two items from the stack and assign them to keys x and y?
Here is how you accomplish this in 0.5
Problems:
;
) items so you can assign the next onesOverall this feels clunky, the dict literal doesn't interact with the main structure of the language (the stack) well
With the new syntax, you can use a plain header like you would for a block. Here is code that creates the same dict literal from above:
You can specify additional variables in the literal as you normally would
Block and dict headers have the same syntax (and use the same implementation internally) so you can use all header features in your dict literals that you would in blocks:
1 :{a,}
->:{1:a}
1 :{a, a:b}
->:{1:a 1:b}
1 :{a::num, }
->:{1:a}
1 :{a::str, }
->Type Error
1:a; :{: a^, }
->:{1:a}
[1 2] 3 :{[a b] c, }
->:{1:a 2:b 3:c}