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

[REBOL] Re: Binding

From: robert:muench:robertmuench at: 20-Nov-2002 9:36

> -----Original Message----- > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]] > On Behalf Of Carl at REBOL > Sent: Wednesday, November 20, 2002 1:06 AM > To: [rebol-list--rebol--com] > Subject: [REBOL] Re: Binding > Exactly. It has to be that way. Here's an example of why: > > print-block: func [block] [ > foreach value reduce block [ > print value > ] > ] > > example: has [temp][ > temp: 12 > print-block [temp now] > ] > > The contexts of TEMP and NOW have to be carried with them, > otherwise they can not be known within the print-block.
Hi, I understand this but it's really different to compiled languages. In a compiled language this would be called "call-by-reference". BTW: Are there are any situations where Rebol makes an implicit copy of words where I loose this "by-reference" semantic?
> This is that "variation" on static (syntactic) > binding that REBOL uses. It's not precisely static, because > it can be modified at runtime by functions like BIND, MAKE, FUNC, etc.
And that's what IMO is what "normal" programmers have the biggest problem with. In C++ a variable name and value is a unit. And if you don't change the value it won't change (only if you leave a scope). In Rebol a "variable" (a.k.a word) is just a human-readable-descriptor so that we can write it down. The value of such a word depends on the binding, which is dynamic and context-dependent.
> BTW, named contexts *are* created by MAKE OBJECT...
Right, but at the moment these are more containers for words than useable structures (first-class-object?)
> what you want is a way to pass them as an argument to BIND (rather > than a word from the object). An interesting (and doable) idea.
Exactly! And if it's doable I highly vote for such a feature! And it would be nice to be able to query the (named) context of a word for debugging. When can we see this feature? :-))) Robert