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

[REBOL] Re: Pointers, Context in Rebol 3.0 (For the real Rebol Lovers)

From: gabriele::colellachiara::com at: 24-Mar-2007 11:30

Hi Giuseppe, On Friday, March 23, 2007, 9:17:11 PM, you wrote: GC> aaa is no longer usable and it is reported to have no value. It seems rebol GC> is not able to bind the new F1 to the context of the parent object. It's not able to do so *automatically*. (And it shouldn't.) You just need to use BIND.
>> o: make object! [f: does [a] a: 1] >> o/f
== 1
>> f2: does [a] >> o2: make o [f: :f2] >> o2/f
** Script Error: a has no value ** Where: f ** Near: a
>> bind second :f2 o2
== [a]
>> o2/f
== 1 GC> There could be a way to change this situation in Rebol 3.0 ? Short answer: no. GC> a1: func [a b] [a / b] GC> inst1: make template [f1: :a1] GC> inst2: make template [f1: :a1] GC> I expect that both inst1 and inst2 share the same "pointer to a1" No - your model is just wrong here. You have three different words and all refer to the same value. If you change the value a word is referring, there's no reason why the value any other word is referring should change. a1 -----\ f1 --------> func [a b] [a / b] f1 -----/ You are just changing the arrow for a1; this operation should not have any effect on the arrows of the two f1. (They don't even know about a1.) (Please note that the above diagram is simplified.) GC> Performing a: GC> a1: func [a b] [a / b + 1] GC> should change both INST1/f1 and INST2/f1 because they should point to the GC> same function as I have declared [F1: :A1]. Just use something like f1: func [a b] [a1 a b] instead. GC> For rebol 3.0 I ask you the ability to point to an external function like GC> having a pointer to a function in C. Changing the pointed function should GC> change the working of F1 in both the declared objects. Changing the pointed function means something like: change second :a1 and *not* a1: some-new-thing The latter does *not* change the "pointed" function. GC> If you introduce the "pointer to function" concept in some way we could GC> declare (for example) 10.000 object and change the working of their inner GC> functions with a simple line of code because we have declared them as GC> pointers and not locally copied. They are *not* copied, they are the same function value. (And this is actually a problem, because it can't be bound to different contexts!) But changing the word does not change the value. Regards, Gabriele. -- Gabriele Santilli <gabriele-rebol.com> --- http://www.rebol.com/ Colella Chiara software division --- http://www.colellachiara.com/