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

[REBOL] Re: Obscure? You be the judge!

From: joel:neely:fedex at: 18-May-2002 10:34

Hi, Ladislav, Ladislav Mecir wrote:
> <<Romano>> > > 3) I did not test your code, but it seems to me that it bind the > body function to the new context. This is only half correct: > binding is done in Rebol before adding the new set-words of spec > to the new object: > > d: "global" > a: context [b: does [print d]] > a/b; == global > a2: make a [d: "local to a2"] > a2/b; == global > > As you can see, the d word in the func body is not binded to the > a2 context. > But: > > a: context [b: does [print d] d: "local to a"] > a/b; == local to a > a2: make a [d: "local to a2"] > a2/b; == local to a2 > > <</Romano>> > > <<L>> > > Thanks for your analysis. This behaviour is really complicated. > (I wonder what will Joel say to this?) >
He didn't say anything. He just ran from the room screaming incoherently!!! ;-) Seriously, I wasn't nearly as surprised by this example as I have been by some other "interesting" examples. Since encountering REBOL I have been on a (non-terminating ;-) quest to find the simplest possible model/principles from which to understand and describe the behavior of the language. For example, once one understands the way REBOL uses the concepts of "word" and "context" it is follows very logically that in the following: a: make object! [ p: 42 q: "Howzabout them apples?" r: func [] [ pick q (length? q) // p + 1 ] ] b: make a [ p: 7 q: "I have nothing to say and I am saying it." ] each of A and B must have its own copy of R with no code-sharing. Similarly, the non-intuitive behavior of Romano's example above can be explained fairly simply in terms of the "definition-time binding" rule and the way MAKE OBJECT! treats top-level set-words in the spec block.
>From my mathematical background, I don't see a contradiction in
simultaneously seeing something as "non-intuitive" and "simple" because that background has taught me that intuition is trained by experience. Something outside our everyday experience is likely to be non-intuitive/surprising more from our unfamiliarity with it than from its inherent complexity. Given the fact that different people have different styles of thinking and learning, I conclude that the best way to teach something unfamiliar is to use a combination of *both*: * axiom-like basic principles from which the behavior of the new thing can be deduced (for obsessively top-down, deductive thinkers like me), and * cumulative experience, beginning with simple examples and leading up to the more out-of-the-ordinary cases (for the folks at the other end of the thinking-style spectrum who are more bottom-up and inductive). I'd love to write such an introduction to REBOL one of these days, but feel compelled to learn it better myself before doing so. I also would like to feel a high level of confidence in the stability of the core language concepts. The upcoming dosage of Valium to be adminstered to word evaluation would certainly have made some of my previous models and descriptions inaccurate! ;-) -jn- -- ; Joel Neely joeldotneelyatfedexdotcom REBOL [] do [ do func [s] [ foreach [a b] s [prin b] ] sort/skip do function [s] [t] [ t: "" foreach [a b] s [repend t [b a]] t ] { | e s m!zauafBpcvekexEohthjJakwLrngohOqrlryRnsctdtiub} 2 ]