On 11/5/05, Giuseppe Chillemi <[EMAIL PROTECTED]> wrote: > Hello, I am starting my experiments with Rebol. I want to write a small > application to learn more about Rebol objects. > > > > I need to have an array of the same object. The object contains data and > code (methods). The methods code should be defined at the creation of the > instance of the object. The method "interface" will always be the same an= d > method will have 5/6 different kind of code in N (even >10.000) instance= s > the object. > > The question are: > > - does Rebol create in memory a new instance of the method code for each > instance of the object ? > > - could I reuse the same 5/6 kinds of code without duplicating the code i= n > memory when I generate a new instance of the same object (In other words= a > relative link to code) ? > > > > The main goal is to save memory and have speed. >
; Its a little awkward, but possible. ; view-faces do it similar to this: methods1: context[ f1: func[obj][print ["f1 on" obj/type obj/name]] ] proto-f1: func[obj][ obj/methods/f1 obj ] proto1: context[ name: none type: 'proto1 methods: methods1 ] ; subclass: methods2: make methods1[ f1: func[obj][print ["f1 on" obj/type obj/name]] ] proto2: make proto1 [ type: 'proto2 methods: methods2 ] ; instance: inst1: make proto1 [name: "inst1"] inst2: make proto2 [name: "inst2"] proto-f1 inst1 proto-f1 inst2 > > > Thank you in advance > > > > Giuseppe Chillemi > > > > > > > > -- > To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject. > > -- -Volker "Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem." David Wheeler -- To unsubscribe from the list, just send an email to lists at rebol.com with unsubscribe as the subject.
