You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is to make sure type proposals using generics works without conflicts with future library features. The big picture of generic objects is to allow very compact Map initialization and key-value iteratation. Record generics would use an identical syntax as below.
Note that sets are already elegant:
consta:Set<uint32> = [0, 1, 2, 3];
Generic object syntax would look like:
{}<K,V>
This allows one to define key and value types for every object. This is mostly useful on maps.
The generic parameter syntax is not backwards compatible and ambiguous (probably technically requiring unlimited lookahead to parse), since [0] < foo is already a valid (if non-sensical) JavaScript less-than expression.
This is to make sure type proposals using generics works without conflicts with future library features. The big picture of generic objects is to allow very compact Map initialization and key-value iteratation. Record generics would use an identical syntax as below.
Note that sets are already elegant:
Generic object syntax would look like:
This allows one to define key and value types for every object. This is mostly useful on maps.
Currently one can do:
Turns into this (if you assume the key was supposed to be an uint32 and not a string) if you use the implicit constructor casting:
The generic object syntax would be ordered. So objects are inserted into the map in the order they appear.
In the far future this would be changed to:
The syntax supports any key types, so strings aren't a limitation.
If the key is a string it does require quotes in this syntax or its is treated as an identifier.
Note that template strings are used for computed strings in this syntax. Consider:
Arrays can be keys. Not sure what that means, but it's allowed in this syntax. I've never needed it.
Iteration looks like:
The text was updated successfully, but these errors were encountered: