More compiler oddities
BradC
Posts: 2,601
Just for the record.
You don't need to declare a CON block.
Starting the file with..
FRED = 24, A = 1, B = 2
.. works perfectly..
You don't need to declare your enumerators from zero.. it happens by default in the con block..
so
CON A, B, C
za = 24, zb = 25
D, E, F
will give you A = 0, B = 1, C = 2, D = 3... and so on..
You can space your enumerators..
#0, A[noparse][[/noparse]10], B[noparse][[/noparse]10], C[noparse][[/noparse]10]
will give you A = 0, B = 10, C = 20..
And you can use pre-defined constants and mathematics in the [noparse]/noparse fields..
so
zz = 20
A[noparse][[/noparse]zz], B[noparse][[/noparse]zz+10], C[noparse][[/noparse]zz]
will give you A = 0, B = 20, C = 50..
You never know when it might come in handy [noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pull my finger!
You don't need to declare a CON block.
Starting the file with..
FRED = 24, A = 1, B = 2
.. works perfectly..
You don't need to declare your enumerators from zero.. it happens by default in the con block..
so
CON A, B, C
za = 24, zb = 25
D, E, F
will give you A = 0, B = 1, C = 2, D = 3... and so on..
You can space your enumerators..
#0, A[noparse][[/noparse]10], B[noparse][[/noparse]10], C[noparse][[/noparse]10]
will give you A = 0, B = 10, C = 20..
And you can use pre-defined constants and mathematics in the [noparse]/noparse fields..
so
zz = 20
A[noparse][[/noparse]zz], B[noparse][[/noparse]zz+10], C[noparse][[/noparse]zz]
will give you A = 0, B = 20, C = 50..
You never know when it might come in handy [noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pull my finger!
Comments
Using that technique, here's an easy way to express a Fibonacci sequence using CON:
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
It certainly has the potential to be useful anyway..
Another "interesting" point is the [noparse]/noparse block does not need to be attached to its parent. Whitespace is gracefully ignored.
ie
CON
A [noparse][[/noparse]10] , B [noparse][[/noparse]10]
VAR
long Fred [noparse][[/noparse]15]
are all perfectly valid.. it makes it easier when looking at it from the perspective of a tokenizer..
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pull my finger!
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
Phil: I love that fibo sequence idea.
"Makes sense" In a kind of Alice in Wonderland way. Strangest syntax for enums I ever saw.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
So this enumeration syntax seems to be expected, but not documented in the Manual.
Andy