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

[REBOL] Re: Ready for REBOL/Core 2.6?

From: pwoodward:cncdsl at: 8-Mar-2002 12:14

> On Fri, Mar 08, 2002 at 10:34:35AM +0100, Cyphre wrote: > > Holger(RT), > Carl may have been exaggerating there. The reason why objects cannot be > extended is the same reason why there is currently a limit on the number > of words in the system (which, btw, will be increased from 4000 to 8000 > in Core 2.6). We do intend to lift these restrictions, but doing so is not > trivial, and it most likely won't be in 2.6.
How would extend be significantly different than using the following? ; start example example: make object! [ the-time: now/time set-time: does [the-time: now/time] ] timer: make example [] ; end example In this case, "example" is being used as a prototype object. It is cloned (rather a new instance of it is created) as "timer". In theory (unless I'm missing something) "timer" is now seperate from the original "example" and can be modified independently. New variables and functions can be added to timer without affecting "example". Now, I realize this isn't quite the same as // Start Example class MyOldObject { public Timestamp theTime = new Timestamp(System.currentTimeMillis()); public void setTheTime() { this.theTime.setTime(System.currentTimeMillis()); } } class MyNewObject extends MyOldObject { } // End Example Because - in Java there is a difference between a class and an object. The class is a blueprint, the object is an instance. In Rebol this distinction is blurred. Using make object! essentially creates the class/object at the same time - the word you are defining is both a class and an instance of that class all at once. So - when you choose to make a new word/value pairing (like timer: make example []) you're in effect creating a new class and instance of that class all in one. You can then freely override the variables and functions of the newly created object as you see fit... Sorry to ramble so much - and I could be dead wrong, but this is just the way Rebol seems to behave when compared to other languages. - Porter Woodward