Comments on: Decision on multicontext variable lookup
I recently asked the question: Is there value in providing a method to lookup variables over multiple contexts? (blog 138)
This question bubbled to the top from an addition made to the delect function. There are times when using delect on a block where you want the variable values to be obtained from a specific context or better yet, a collection of contexts.
After a couple weeks of evaluating this question and trying a few examples, I've reached these conclusions:
- Multicontext lookup is useful for the singular lookup in function. It saves steps and can speedup your code. So, this feature will be provided.
- Multicontext lookup is not useful for block evaluation (the delect and the reduce functions.) It is slower, and in fact would slow down the entire evaluation process (because it adds overhead to the runtime state of the interpreter).
To handle the block evaluation cases, it would be better to provide multcontext binding in the bind function by allowing:
bind block [context-1 context-2 ...]
We've talked about doing this before, so perhaps the time has come to do so.
Also, this can also be optimized to be many times more efficient than a evaluation-time multicontext lookup.
That will definitely help, and keep the speed we have come to enjoy in REBOL. I look forward to seeing what can be done with these additions.|
I may be late on this issue, but I think it is better to promote "object" management of variables rather build a process of blindness.
This will complement the post on func-local, namely: I think it is better if the programmer had a thought for a global variable (bearing in mind the consequences of such a choice). In doing so it will reflect on the contexts and could choose to integrate its variable in an object.
Paul, you will probably like R3's modules. That is how R3 is managing contexts - there won't really be a global context, just module contexts, exported and imported words.|
Post a Comment:
You can post a comment here. Keep it on-topic.