jaegs wrote:Similarly, why is the "of" keyword required in generics?List<of int>
It seems obvious to me that whatever is inside the angle brackets is a type and no other decoration is necessary. Plus, I imagine really long generics could get messy (well, messier than they already are)IEnumerable<of List<of Dictionary<of string, int>>>
What should the parser presume when it processes the following?
a = B < C ...
Is that the start of a generic or a comparison between B and C?
So "of" is to eliminate ambiguity with the less-than operation which is "<". Of course, we know this is not strictly necessary because C# does not take this approach. So I took a peek at someone's C# parser to see how they did it. There was something hackish in the parser to pull it off. The rest of the grammar was parsed in a straightforward manner, but then "B < C" required some major back bending. And maybe we could do the same, but the C# parser got me thinking: "it really is kind of ambiguous". Also, it may be more difficult for Cobra because types can be directly referenced:
t = List<of int>
# in C#: t = typeof(List<int>)
But then maybe we could get into casing: Cobra requires types to be capped while params and locals must start lower cased. Throw in the fact that classes cannot be compared for ordering and we could have our disambiguation approach right here.
Although Cobra can't push the casing restrictions on .NET libs produced in other languages. On the other hand, it's rare to see a lower cased generic class in a library and "<of" could be the fallback for using such poorly styled libraries.
So there are possibilities that could be explored for implementing it in the Cobra parser.
How do people feel about "of"? Don't care? Like it? Dislike it?
Usually such questions are problematic as you'll mostly get answers from the discontents who may be outnumbered by the contents who aren't energized enough to speak up. In any case, it's open to discussion.