Ciao Christian,
This does not seem a good solution for my problem.
Method must be defined inside the object during the creation and should be
only a reference to a function assigned to the method values at object
creation. It must not be the function itself. I want to be able to:
- change the function and have it changed in all the objects created with
reference to this function
- have the 4/5 same instances of code in memory for 10.000 object which uses
the same code.
Example:
REBOL [
Tittle: "Array experiments"
version: "0.1"
]
func1: func [func_obj] [print func_obj/v1]
func2: func [func_obj] [print func_obj/v2]
tipo1: make object! [
v1: "val1"
v2: "val2"
f1: []
f2: func [obj] [print obj/v2] ;not meaningful
f3: does [f1 self]
f4: does [func1 self]
]
obj1: make tipo1
obj2: make tipo1 [f1: :func1]
I want to write, somewhere after obj2 creation, this line of code:
func1: :func2
And have f1 changed inside obj2 and f3 executing func2 instead of func1.
f4 seems to be a perfect solution but I don't know ho to change it to
f4: does [<my_preferred_function_for_this_object> self]
during the object creation.
Example:
obj2: make tipo1 [f4: ***********]
where ************ could be, in this particular situation: "does
[func2 self]"
Giuseppe Chillemi
-----Messaggio originale-----
Da: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Per conto di
Christian Ensel
Inviato: domenica 6 novembre 2005 23.30
A: [EMAIL PROTECTED]
Oggetto: [REBOL] Re: Question about REBOL objects and reusabilty of code
(Correction)
Hi Giuseppe,
>If the answer is yes, what about the visibility
>of local variables I could define in the object from the function a1 ?
>
>
One easy solution is to hand over the object itself to the functions as
an argument:
>> proto: make object! [value: none]
>> object-a: make proto [value: 1]
>> object-b: make proto [value: 2]
>> method: func [object] [probe object/value]
>> method object-a
1
== 1
>> method object-b
2
== 2
>>
Hth,
Christian
--
To unsubscribe from the list, just send an email to
lists at rebol.com with unsubscribe as the subject.
--
To unsubscribe from the list, just send an email to
lists at rebol.com with unsubscribe as the subject.