Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Embedded Object and Scope yet again...

From: gjones05:mail:orion at: 11-May-2001 6:49

From: "Larry Palmiter" <major snip>
> There are a couple of facts about "embedded" objects which are good to
know:
> 1) Sub-objects which are defined with a set-word in the parent object
are
> treated differently than other datatypes when the object is cloned. > Sub-objects are not cloned, the pointer (which what a word really > references) still points to the original sub-object. Other datatypes
are
> copied into the cloned object. > . > 2) Sub-objects exported with your do [] construct or by using SET are
not
> really "embedded", the words which reference them are global, but the
words
> contained in their definition blocks are bound to the context of the
object
> in which they are created. To me it is similar to this example:
These are good rules to remember and add some real meat to the potatoes. I am still struck by how none of this is explicitly obvious. I feel positively evangelical about REBOL, but this area is one of those areas that makes me feel particularly nervous, like the only way that I feel like I would know what I was doing would be to always do some major experimenting and value checking along the way. I don't believe that I could write a section of code in these techniques and expect it to run right the first time. Most of REBOL does work this way for me, meaning it runs the way I would expect. I guess that this area will be one of those less-intuitive paradigms to be learned and integrated.
> >> b: [] repeat j 3 [use [x][x: j append b 'x]] > == [x x x] > >> b > == [x x x] > >> reduce b > == [1 2 3]
This looks like total magic. I actually felt compelled to rerun the example to be sure that it works (not that I didn't believe you, but it was like wanting to see a magic trick again). Conceptually, I can understand what is happening, but, wow. I keep trying to figure out how this code is represented in memory.
> The word b is in the global context, it's value is a block which
contains
> the words x, x, and x each of them created in a different unnamed
context.
> You can do much the same thing in LISP, Scheme or other symbolic
programming
> languages.
I guess that this is the critical point for me: I've had very little experience in using truly symbolic languages. <remainder snipped> Thanks, Larry, your additional discussion has helped to shed further light on this topic. Regarding intuition, I am reminded of a medical school professor who repetitively said in lectures that this, that and the other principle were "intuitively obvious" and therefore required no further lecture time for explaination. We students sat in stunned silence. I realized that anything becomes intuitively obvious after working in a subject area for 20+ years. It was John Dvorak (computer tech pundit) who first articulated this concept, that intuition was largely a learned experience. I think he is right. I await the day when REBOL scoping rules and parsing become intuitively obvious. --Scott Jones