Elan wrote:
-----
The
> following mechanism can be used to avoid inheriting some code. It uses use
> contexts:
>
> ancestor: make object! [
> do-something: none
> use [var-1 var-1 comment {more vars here} func-1 func-2 func-3 ] [
> var-1: "this is var-1"
> var-2: "this is var-2"
> ;- more vars here ...
> func-1: func ["extremely long function. don't inherit."]
> print "func-1: tons of code here"
> ]
> func-2: func ["also extremely long function. don't inherit."]
> print "func-2 tons of code here"
> ]
> do-something: func ["this function will be inherited"] [
> func-1
> func-2
> ]
> ]
> ]
>
> descendant: make ancestor []
>
> >> descendant/do-something
> func-1: tons of code here
> func-2 tons of code here
> >> probe descendant
>
> make object! [
> do-something: func ["this function will be inherited"][
> func-1
> func-2
> ]
> ]
>
> ;- Elan
---------
There are two problems with your solution:
a) it is relying on the persistence of func-1, func-2, ..., which is not
garanteed now (problem with indefinite extent and garbage collector...)
b) the uninherited functions can access only the ancestor's attributes and
not the descendant's
I think the only reliable method is to define the uninherited functions
outside of the object and submit them one more parameter - the object to
operate on.
Ladislav