REBOL Technologies

Extending EXTEND

Carl Sassenrath, CTO
REBOL Technologies
24-Sep-2010 3:08 GMT

Article #0488
Main page || Index || Prior Article [0487] || Next Article [0489] || 10 Comments || Send feedback

For a few of you gurus...

Today, while redesigning the boot sequence for R3, I wanted to make the runtime library system/contexts/lib but without the "noise" of local words in the context.

As you know, when you load a block of code (or data) new bindings are created for all words. This is done to avoid the problem of forward references. Early on in the development of REBOL, we decided that this method was usually worth the "cost" of local words appearing in the target context.

Of course, that behavior is not a strict requirement. If you happen to know all defined words, or can somehow detect them, then you don't need to allocate slots for any other words. In fact, that's how objects are made. They are designed such that their set-words are definitive. All other words must be from higher or lower level contexts.

Now, we haven't really codified this method as an official function. Sure, most of you might know how to use bind to get the desired result, but it seems to me it would be worthwhile to provide it in the system. While most programmers won't care, gurus will find it quite useful, especially when building precise run-time contexts. (Like what I'm doing right now for the boot code.)

When using this method to add to an existing context, it certainly seems like this feature belongs in extend (mezzanine function.) Two forms could be supported:

extend/with acontext words-block eval-block

This provides the list of words to append to the context, followed by a block that is evaluated.


extend/with acontext 'set eval-block

which acts uses the set-words of the eval-block as the word, just like make of objects.

Yes, I know, we've probably all written something like this before for our own apps, but it's time to nail it down and add it as an official feature.

Let me know your thoughts.


Updated 7-Mar-2024   -   Copyright Carl Sassenrath   -   WWW.REBOL.COM   -   Edit   -   Blogger Source Code