Change Generics Syntax
thbwd opened this issue Β· comments
βοΈ Proposed change
The syntax for generic argument/parameter lists must be changed. There are two options I have considered so far:
-
The list begins with π and ends with π.
π¨ππ‘π π₯ππ‘π‘π’π
-
The list begins withβοΈ and ends with π.
π¨βοΈπ‘π π₯βοΈπ‘π‘π’π
π is used for consistency with current list/dictionary literals and will be changed when their syntax is finalized.
π€ Rationale
The current syntax is ambiguous:
πππππ‘
Grammar-wise it is not clear here whether ππ‘
is an argument to π
or an argument for ππ. This is impractical for parsing in certain situations as well as it can be confusing to the programmer. With the new syntax there is no ambiguity:
ππππ‘π
π or (depending on what the above meant)
πππππ‘ππ
πΊExample
Some more examples:
π ππKey βͺοΈ Element βͺοΈπ π
π ...
π
π πβοΈKey βͺοΈ Element βͺοΈπ π
π ...
π
βοΈ β β‘οΈ π¬ππKey Elementπ π
β©οΈ next
π
βοΈ β β‘οΈ π¬πβοΈKey Elementπ π
β©οΈ next
π