spin2 compiler error ?
psttiger
Posts: 2
in Propeller 2
Object array setter compile but geter do not compile
File 1 obj_x
VAR
x
PUB setX ( v )
x := v
PUB getX ( ) : v
v := X
File 2 test use of obj_x
OBJ
o : "obj_x"
o1[2] : "obj_x"
PUB go () | x
o.setX(55) ' Compiled ok
x := o.getX() ' Compiled ok
o1[0].setX(55) ' Compiled ok
x := o1[0].getX() ' Compiled with Error
' ^
' - Error: Expected "."
Is that a compiler Prolem ?
File 1 obj_x
VAR
x
PUB setX ( v )
x := v
PUB getX ( ) : v
v := X
File 2 test use of obj_x
OBJ
o : "obj_x"
o1[2] : "obj_x"
PUB go () | x
o.setX(55) ' Compiled ok
x := o.getX() ' Compiled ok
o1[0].setX(55) ' Compiled ok
x := o1[0].getX() ' Compiled with Error
' ^
' - Error: Expected "."
Is that a compiler Prolem ?
Comments
One problem might be a missing RETURN v at the end of PUB getX ( ) : v.
Spin1 has a implicit return, Spin2 does not.
Please clarify what compiler you are using, Fastspin does P1 and P2, Pnut also but slightly different PropellerTool alpha also P1 and P2, PropellerTool (original) just P1.
As far as I can see it should work, so the syntax you are using is correct.
Mike
x := o.getX() ' Compiled ok with Compiler Propellertool 2.2.0.0 Alpha, Flexgui 4.2.4 , PNut_v34w
o1[0].setX(55) ' Compiled ok with Compiler Propellertool 2.2.0.0 Alpha, Flexgui 4.2.4 , PNut_v34w
x := o1[0].getX() ' Compiled with Error
' ^
' - Error: Expected "." Propellertool 2.2.0.0 Alpha with RETURN and without RETURN
' error: syntax error, unexpected ')' Flexgui 4.2.4
' no Error with PNut_v34w (if RETURN v)
' x := o1[0].getX Compiled ok with Flexgui 4.2.4 with RETURN and without RETURN
It should be the case that the spin2 syntax is treated the same by all compilers
Looping @ersmith in
EDIT: And @cgracey @"Jeff Martin" for the Propellertool (if I'm not mistaken about the above output, anyway? It looks like PropTool failed at least one test case above)
FWIW, in 14 years of Propeller programming I have used object arrays exactly one time in a client project.
Update: The same program compiles with the latest version of PNut.
It seems that the Spin2 compiler (in PNut.exe) is not recognizing object arrays as parameters, but it is recognizing them as instructions. I'm working on it.
http://forums.parallax.com/discussion/171196/pnut-spin2-latest-version-v34x-graphical-debugger-improved-object-array-bug-fixed/p1