hello,
just a thought, that it would be nice if we could use symbols in translated code. They don't have to carry any associated value(s) like classvars, but instead could be used as unique identifiers.
struct sqSymbol { };
#define declareSymbol(name) struct sqSymbol sqSym_##name #define sqSym(name) &sqSym_##name
declareSymbol(foo);
each time translator sees code like:
(a == #foo ) ifTrue: [ ]
it could generate a following code:
if ( ((sqSymbol*)a) == sqSym(foo)) { .... }
Just a single example of application of it:
Currently a CogRTLOpcodes defines a lot of symbolic constants , like ... Jump JumpAbove JumpAboveOrEqual JumpBelow JumpBelowOrEqual ...
and the values of these constants carry no any additional semantic load, and could be replaced by simple unique values (which is symbol objects in smalltalk).
If i remember correctly , currently a symbol literals in method frame are translated to strings. But in practice i think there are very few of such uses, because using string literals is less confusing and more intention revealing.
While using symbols in a way which i propose could simplify some code.
There is of course a different way how to translate symbols: - a code generator could contain an incrementing counter for each symbol it meets in code and then and the end it generates a symbols.h file which looks like:
... #define foo 1 #define bar 2 .. and so on.
vm-dev@lists.squeakfoundation.org