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

[REBOL] Re: Binding

From: robert:muench:robertmuench at: 19-Nov-2002 14:24

> -----Original Message----- > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]] > On Behalf Of Ladislav Mecir > Sent: Tuesday, November 19, 2002 12:57 PM > To: [rebol-list--rebol--com] > Subject: [REBOL] Re: Binding > > So, it really seems to be that bind is one-shot action. > > I am not sure I understand what you mean here... > > > Every word that get's bound to the > > local context after BIND isn't accessible from the bounded block. > > Again, I don't think, I understand...
Hi, ok I try again with the goal to finally understand this. Can't believe it but even after years of Reboling it sometimes surprises me... And I just read some of your words, etc. stuff from your Rebol page. But it's really hard stuff... Anyway: Let's get back to my first code snippet: forall-records: func [list predicate action /local object][ if any [none? list empty? predicate empty? action][return none] list: select list 'values predicate: bind/copy predicate 'list action: bind/copy action 'list ; iterate through the whole list of values ; check if the first entry satisfies the predicate ; if so execute the action. foreach [id object] list [ if do predicate [do action] ] ] result: make block! [] forall-records graph/nodes [?? object][append result id] And see what I think we have (please correct if wrong): 1. result is bound to the global context 2. Are OBJECT, RESULT and ID bound at all? Where? Global context? 3. Now the function call happens. LIST PREDICATE ACTION are set as aliases to - graph/nodes - [?? object] - [append result id] 4. action will be set to a copy of [append result id] with the words bound to ?? And now I'm lost... Is there a graphical picture that shows how all this binding etc. stuff works together? I said one-shot because IFAIK the binding of a word can't be changed once set.
> No such information exists. A block can contain words. Every > word in a block has its own binding attribute.
Ok, that's something I can imagine. Is there a binding visualizer available? I would like to see where a word is bound to, not only get the message: It's not bound to the actual context.
> No. FOREACH binds its BODY argument appropriately.
At the moment the body is evaluated the first time?
> Unfortunately, if you use variables 'predicate and 'action, > FOREACH binds only the variables instead of the values they represent.
Hmm... Does this make any sense? What does is mean "binds only the variables..." So these have no values at all?
> The code containing COMPOSE doesn't allow FOREACH to bind the > variables, because it replaces the variables by their > contents before BODY is supplied to FOREACH, and that is why > FOREACH is allowed to do what is needed.
Ok, I think I got this. So I can think of this like doing a textual replacement (but keeping the origianl binding). Robert