Today, indexing into an array uses syntax like array.0. This syntax also works if the index is a variable, i.e. array.i. The issue is that the variable i is resolved in the global namespace, i.e. you need something like:
If we want to have better support for OO style language, this syntax conflicts with that of the object method call, i.e. foo.bar where foo is an object and bar is a method of foo. Basically, the expression foo.bar is ambiguous because it is clear whether it is a array/dict member access or object method call, especially if we want to have member methods for array/dict. In most other languages, this is solved by having the syntax of foo.bar dedicated to object method call and foo[bar] for member access. So the proposal is to have something like the follows:
// array or dict element access
a[0]
a.0
a[b] // b is resolved
a.@b // b is not resolved
// method call
a.b // b is not resolved
This is useful if we want to have full OO support, which by itself is a question.
Today, indexing into an array uses syntax like
array.0. This syntax also works if the index is a variable, i.e.array.i. The issue is that the variableiis resolved in the global namespace, i.e. you need something like:If we want to have better support for OO style language, this syntax conflicts with that of the object method call, i.e.
foo.barwherefoois an object andbaris a method offoo. Basically, the expressionfoo.baris ambiguous because it is clear whether it is a array/dict member access or object method call, especially if we want to have member methods for array/dict. In most other languages, this is solved by having the syntax offoo.bardedicated to object method call andfoo[bar]for member access. So the proposal is to have something like the follows:This is useful if we want to have full OO support, which by itself is a question.