Hi guys,

Sorry, can't remember all the names. Have little time. 

Someone observed that descendant objects inherit their ancestor object's
function implementations and variables. This leads to inflated code. 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


Reply via email to