parentheses for arrays?
- kevclark64
- Posts: 127
- Joined: Thu Aug 15, 2019 7:30 pm
- Location: USA
parentheses for arrays?
I'm wondering what the prospects are for being able to use parentheses for arrays in the Foxpro dialect. Right now, any code that is converted from FoxPro must have square brackets for arrays.
parentheses for arrays?
Kevin,
We will try to add this support, but it is not as easy as you may think.
The compiler needs to distinguish between
and
and this needs "context" information, so if can only be done in a later phase in the compiler.
Wen the parser sees the parentheses it cannot decide what this will mean. After a lookup has shown that SomeFunction is a function and SomeVariable a variable then the compiler can resolve this.
With the
syntax, this is much easier, since this is less ambiguous.
In FoxPro this work differently since FoxPro is not a real compiler. It converts this into a list of tokens and evaluates the expression at runtime and does a lookup.
Robert
We will try to add this support, but it is not as easy as you may think.
The compiler needs to distinguish between
Code: Select all
SomeFunction(1,2)
Code: Select all
SomeVariable(1,2)
Wen the parser sees the parentheses it cannot decide what this will mean. After a lookup has shown that SomeFunction is a function and SomeVariable a variable then the compiler can resolve this.
With the
Code: Select all
SomeVariable[1,2]
In FoxPro this work differently since FoxPro is not a real compiler. It converts this into a list of tokens and evaluates the expression at runtime and does a lookup.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
parentheses for arrays?
Robert,
If the array is declared as a variable, and so an unambiguous context is provided to the compiler, would it be possible to support the parenthesized syntax for addressing the array's element?
If the array is declared as a variable, and so an unambiguous context is provided to the compiler, would it be possible to support the parenthesized syntax for addressing the array's element?
parentheses for arrays?
Antonio
as a "InvocationExpression"
and later when the binder detects that Foo is a local variable and not a function/method then it converts that to an ArrayAccessexpression.
We can probably do the same. We "just" need to make sure not to break anything else.
Robert
I checked how the Roslyn parser for VB does this, and it parsesatlopes wrote:Robert,
If the array is declared as a variable, and so an unambiguous context is provided to the compiler, would it be possible to support the parenthesized syntax for addressing the array's element?
Code: Select all
Foo(1,2)
and later when the binder detects that Foo is a local variable and not a function/method then it converts that to an ArrayAccessexpression.
We can probably do the same. We "just" need to make sure not to break anything else.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu