Decision on multicontext variable lookup

Carl Sassenrath, CTO
REBOL Technologies
18-Jun-2008 21:29 GMT

Article #0140
Main page || Index || Prior Article [0139] || Next Article [0141] || 3 Comments || Send feedback

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.


Updated 15-Jun-2024 - Edit - Copyright REBOL Technologies -