[VFP] Cannot call parent method of specific class in the hierarchy with the :: operator in VFP dialect
Following results to error XS0432: Alias 'BaseClass' not found for the 2 parent method calls with "::". I assume the only way to make this work is via a late bound reflection call.
FUNCTION Start() AS VOID
LOCAL loClass
loClass = CreateObject("SubClass3")
loClass.ShowMessage()
RELEASE loClass
DEFINE CLASS BaseClass // AS CUSTOM
PROCEDURE ShowMessage
WAIT "Hello from BaseClass"
ENDPROC
ENDDEFINE
DEFINE CLASS SubClass1 AS BaseClass
PROCEDURE ShowMessage
WAIT "Hello from SubClass1"
ENDPROC
ENDDEFINE
DEFINE CLASS SubClass2 AS SubClass1
PROCEDURE ShowMessage
WAIT "Hello from SubClass2"
ENDPROC
ENDDEFINE
DEFINE CLASS SubClass3 AS SubClass2
PROCEDURE ShowMessage
WAIT "Hello from SubClass3"
* Call the BaseClass method
BaseClass::ShowMessage // error XS0432: Alias 'BaseClass' not found
* Call the subclass1 method
SubClass2::ShowMessage // error XS0432: Alias 'BaseClass2' not found
ENDPROC
ENDDEFINE
This is the first time I have seen this syntax.
- use Super instead of the classname
- use BaseClass() to call a static method
- To call a procedure we also need to add parentheses
- calling an instance method from another branch in the class tree is not support in dotnet like this
Robert, yes I know how to change the code, but apparently this is common in VFP, so it would mean A LOT of changes in existing code for apps ported from VFP. And the problem is that there may be a lot of classes in the hierarchy, so it's not good to use something like SUPER:SUPER:SUPER:MethodInThatParticularLevel().
If such a call (with "::") is translated by the compiler to a runtime call, it can be implemented via reflection (calling a method in a specific parent class level)
Correction!!! Irwin just told me that this is not commonly used at all! So let's ignore this for now.
The '::' operator has a special meaning in X#.
I was afraid we would need to somehow support this, one way or the other. But apparently it's not necessary. Maybe reconsider it it in the future, in case several VFP developers request this...