Hi!
"Andreas Raab" andreas.raab@gmx.de wrote:
So given that - how do we fix it? Introduce a new way to refer to "globals", some kind of "binding" object?
The simplest way is probably to introduce a pseudo-operator like for example, "&" to refer to the binding object. For example:
&Foo isUndeclared "answers true if binding is undeclared" &Foo ifUndeclared:[...] "eval if binding is undeclared" &Foo ifAbsent:[...]. "eval if binding's value isn't present"
etc. with &Foo being a simple compiler hack which instead of emitting pushLiteralVariable bytecode (e.g., pushing the value of the binding) merely emits pushLiteralConstant (e.g., pushing the binding itself).
Given my foray into Compiler land (Namespaces package) this doesn't seem hard to do at all. In fact, I get very tempted. :)
(note that in order to do this it would be extremely worthwhile to get away from using Associations and instead make some specific VariableBinding objects which implement the above methods)
Right.
Cheers,
- Andreas
Now... I don't really know what I am talking about - but is this in fact a special case of something bigger, something similar to hygienic macros or whatever it is called? (Slate, Scheme etc) I mean, some way of manipulating the AST of the code itself (which is my very shallow understanding of what that is)?
Just curious.
regards, Göran