> And, crucially for your mental model:
> inst1/f1 is not the same as inst2/f1:

...

> So if you have functions in your object, they will be
> replicated in all its instances. Not a good way to save space.


> I tend to have a "function object" which you could 
> think of as the method, and a set of "variable objects" that contain the
data.

Sunanda, regarding your example

template: make object! [
    f1: func [a b] [a + b]
    f2: func [a b] [a * b]
    v1: now
    v2: []
    v3: copy []
]

Could I change the template into this:

a1: func [a b] [a + b]

inst1: make template [f1: :a1]
inst2: make template [f1: :a1]

If the answer is yes, what about the scope of a and b ?

I need to make 10000 instances of the same object but the code of the
functions must be reused and be able to access the local variables. It is
too memory consuming having 10000 times the same 4/5 kind of codes.

Giuseppe Chillemi


-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to