REBOL 3.0

Comments on: How LOAD uses BIND and RESOLVE

Carl Sassenrath, CTO
REBOL Technologies
14-Jul-2009 17:49 GMT

Article #0220
Main page || Index || Prior Article [0219] || Next Article [0221] || 6 Comments || Send feedback

If you look at load in R3 A71, you will notice these two lines:

bind/new data system/contexts/user
resolve system/contexts/user system/contexts/exports

To summarize, here's what's happening:

 bindwith the /new refinement scans data (the block being loaded) and extends the system/contexts/user (SCU) with any new words that are found (not just set-words, all words.) It also binds those words to SCU.
 resolvecopies the values for all words in SCU that also appear in SCE. In other words, it is "importing" their definitions from the master export list into your program context. The export list contains on only system values, but all exported module values (e.g. if you loaded a math module earlier).

These actions take place in load rather than in do for a couple reasons:

  1. We do not know the intended use of any word. It may be evaluated, or it may not (e.g. could be in a list of variables.)
  2. By resolving in load, we don't slow down do, which we want to keep fast.

You can think of this process to be like that of a loading linker that is used in other languages. Most of the time it should be invisible, and you don't really need to think about it.

It should also be mentioned that modules themselves use a similar method, but rather than binding to SCU, they bind to their own private contexts.

Update notice:

In A75 the intern function has been added to combine bind and resolve in a common way. It also solves the problem mentioned by Grabriele below.

6 Comments

Comments:

RobertS
14-Jul-2009 14:44:18
contains on only system values READ contains not only system values I suppose
Gabriele
15-Jul-2009 4:50:06
Carl, the RESOLVE makes UNSET not work on the console; it also has the side effect that any time you do a LOAD, you might get values in words that were previously unset.

I'm not saying this is bad, just that it may need to be documented properly. If you think this is bad, then I think the best solution would be to combine BIND and RESOLVE in one native that only "resolves" new words added to the context.

>> ? system/contexts/user
SYSTEM/CONTEXTS/USER is an object of value:
   system          object!   [product version build license catalog contex...
   quit            native!   Stops evaluation and exits the interpreter.
   help            function! Prints information about words and values.
   resolve         native!   Copy context by setting values in the target ...
   ?               function! Prints information about words and values.
   contexts        unset!    none
   user            unset!    none
   load            function! Loads a file, URL, or string.
   print           native!   Outputs a value followed by a line break.

>> unset 'print >> ? system/contexts/user SYSTEM/CONTEXTS/USER is an object of value: system object! [product version build license catalog contex... quit native! Stops evaluation and exits the interpreter. help function! Prints information about words and values. resolve native! Copy context by setting values in the target ... ? function! Prints information about words and values. contexts unset! none user unset! none load function! Loads a file, URL, or string. print native! Outputs a value followed by a line break. unset native! Unsets the value of a word.

>> unset 'load >> ? system/contexts/user SYSTEM/CONTEXTS/USER is an object of value: system object! [product version build license catalog contex... quit native! Stops evaluation and exits the interpreter. help function! Prints information about words and values. resolve native! Copy context by setting values in the target ... ? function! Prints information about words and values. contexts unset! none user unset! none load function! Loads a file, URL, or string. print native! Outputs a value followed by a line break. unset native! Unsets the value of a word.

Carl Sassenrath
15-Jul-2009 9:31:47
Gabriele, that is a good point - it should only set newer words.
Brian Hawley
15-Jul-2009 14:09:36
Added a request for a possible solution to Gabriele's problem to CureCode (#1113).
RobertS
16-Jul-2009 9:57:10
one of many positive side-effects should be that those of us who want to see a Rebol IDE built in Rebol should be closer to getting one built now - as the IDE will not shatter as easily (even a Smalltalk environment (its IDE) can be broken by the user if they try ... or don't know what they are doing as newbies) It has long concerned me that both PROLOG and ICON typically had no IDE without paying a very high price (adding types in Visual Prolog and opting for Eclipse in Amzi! PROLOG or losing portability - OCaml is another case where Camelia was an embarrassment. Or Ruby Mondrian. Or my amour, Curl, lacking a real class browser let alone a refactoring browser. Some of us who used the Borland C++ for OS/2 don't know why we are using the command line ... some of us are visual but never liked emacs ... even if its just my sprawl of 3x5 filecards ... or a blackboard and chalk. So watch for hypercard's revenge ... ;-)
Carl Sassenrath
16-Jul-2009 23:43:40
RobertS: it's funny isn't it? Very few IDE's have the perfect balance.

My favorites are the ones that amplified my productivity but didn't get in my way. They allowed me to easily set my keymaps, set breakpoints and trace sections, but didn't get too crazy on useless commands that would never be used. They made it easy to write and integrate custom scripts for those difficult or tedious tasks. They managed the screen area nicely - without a lot of needless clutter.

Yes, there's an art and an elegance to a good IDE. Wouldn't it be nice for R3.

Post a Comment:

You can post a comment here. Keep it on-topic.

Name:

Blog id:

R3-0220


Comment:


 Note: HTML tags allowed for: b i u li ol ul font span div a p br pre tt blockquote
 
 

This is a technical blog related to the above topic. We reserve the right to remove comments that are off-topic, irrelevant links, advertisements, spams, personal attacks, politics, religion, etc.

REBOL 3.0
Updated 13-Dec-2024 - Edit - Copyright REBOL Technologies - REBOL.net