Spin Syntax/Semantics
Anyone got any idea about the following constructs in a CON block ?
None of those names exists any place else in the code at the time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Post Edited (heater) : 6/3/2008 7:08:10 PM GMT
CON
a_name = 2, b_name, c_name, d_name 'Etc etc
e_name, f_name, g_name = 2, h_name, i_name 'Etc etc
j_name, k_name, l_name
None of those names exists any place else in the code at the time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Post Edited (heater) : 6/3/2008 7:08:10 PM GMT
Comments
One can type those statements into a CON section and it compiles without complaint.
So the question is what do they actually mean/do ?
How can I put the subject that I forgot onto this thread ?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Page 194
Next question (and yes I am looking in the FM without success so far) are the comparisons < > etc signed or unsigned ?
Guess I could start experimenting as you suggest but it would be nice to see it specified some where.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
CON #2 ' Set "enumerator" value to 2 a_con = $FFFFFFFF < 0 ' a_con becomes FFFFFFFF (or True) b_con ' b_con becomes 2, the enumerator which is then incremented #b_con + 3 ' Set the enumerator to 5 c_con ' c_con becomes 5, the enumerator which is then incremented d_con ' c_con becomes 6, the enumerator which is then incremented
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
const double x = 1.0, y = 2.0, z = 3.0;
·
I don't mean to be picky but just this once
I did say "succinct" and "enumerations". Your example is not an enumeration but a series of constant definitions.
Below are a few examples of enumerations in various languages:
/* Traditinal C way to do enums */ #define CAT 0 #define DOG 1 #define GOAT 2 #define COW 3 // ANSI C or C++ Enums*/ enum { CAT, DOG, GOAT, COW }; // or enum animals {cat, dog, goat, cow}; ' Visual Basic Enum Enum animals cat dog goat cow End Enum -- Ada Enum type Animals is (cat, dog, goat, cow); ' And in Spin, Assuming you are in a CON block already cat dog goat cow
Now I think you'll agree that SPIN takes the cake here with the total absence of keywords, brackets, commas, semicolons or indeed any printable syntactic elements at all !
Imagine you wanted to write a compiler wouldn't you rather just allocate an increasing number to a list of names or parse all that other junk a well?
Of course the other languages have reasons for what they do especially when defining enumeration types.
Cheers.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Spin solves an age old mathematical mystery, what is the square root of minus one ?
CON
i = ^^ -1
Answer seems to be $0000FFFF.
But then i squared should be 1
CON
i = ^^ -1 * ^^ -1
Gives $FFFE0001
Oh well.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
CON zero, one two = one + one #one + two, three[noparse][[/noparse]one + two], six
Is the use of array indexing a constant documented anywhere ?
Seems a very strange idea.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Here's another one anyway, the strangest form of string concatenation ever:
DAT ' These two result in the same strings a_string byte "ABCD" + "EFGH" b_string byte "A", "B", "C", "D" + "E", "F", "G", "H"
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Just remember: commas butt the ends of strings together; plus signs tie them in a knot.
-Phil