Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Speeding up code

From: sunandadh:aol at: 20-Feb-2002 15:19

Joel:
> > ... I've been offline for most of a week up in the hills ... > Welcome back! I'm jealous! ;-)
I'm being punished for it now by having to reinstall everything on the machine from the opsys upwards. I guess it got jealous too and trashed itself.
> > ... If you take this object... > > myob: make object! [ > > var1: 0 > > var2: 10 > > print ["object initialized"] > > func1: [] [print "func 1 called"] > > ] > > > > ...the two var assignments and the print statement will be > > executed as part of the object initialization. > But not when one uses MYOB as a prototype, as in
otherob: make myob There's some oddity going on here -- no doubt explained in the core manual (which I didn't have backed up, and haven't yet redownloaded). The initialization code gets executed and then stripped out as part of building the object. The result of making an object is a series of assignments only, as this example shows: myobj1: make object! [ var1: [] print "initialize" do [append var1 now/precise] func1: [] [print "func1"] ] probe myobj1 myobj2: make myobj1 [] probe myobj2 The 'Do and 'Print are executed during myobj1: make object! [...] but do not survive into the object itself. So that code does not get executed in myobj2: make myobj1 [] That wasn't what I was expecting to see -- so thanks for pointing it out. There's no obvious workaround that I can see. Sunanda.