Is there value in providing a method to lookup variables over multiple contexts?
This question has recently bubbled to the top from an addition made to the delect function. (Delect mainly provides a high-speed parse method for command mapping, argument order marshalling, and value lookup. It is used for dialects like DRAW.)
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.
Delect was expanded to allow:
delect/in dialect input output contexts
Where contexts is a block of contexts to use for resolving the values of variables. An example of this would be in a drawing, where a pen color may be found in one of many style sheets, but also in the primary face object.
This extension of delect raises the question as to whether the technique is generally useful for variable lookup?
color: get in [
face/options frame/options style/options
We might be tempted to think that the equivalent of this is:
color: any [
But, in fact that's not true because if the variable is not in a context, an error will be thrown. Therefore, we would have to write it like this to be safe:
color: any [
get in face/options 'edge-color
get in frame/options 'edge-color
get in style/options 'edge-color
Now, if you consider that pattern within a reduced block, it could add up to a significant amount of code, something we don't like a lot of in REBOL.
Where this really seems to be of values is in the implementation of things like property sheets (like CSS in HTML). The pattern is to look for a property in one context, and if not found, look in a parent context, etc.
The overhead of adding this feature to REBOL is small, because it's already implemented for delect.