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

[REBOL] pseudo-class inheritance at a price ?

From: chrismorency:videotron:ca at: 7-Oct-2001 4:59

Hi, As I mentioned in another post earlier, I've been working for the past three weeks on a pseudo class inheritance library for Rebol/Core. This would enable rebol developers to use class to define object or class inheritance. Why ? The current implementation of object "inheritance" under rebol is done by a way of cloning (ie copying everything) from one object to the other. Hmm and ? What I've been working on enable small objects (in term of memory and method code) to refer big class (with a lot of method code). But ? However, my implementation would require some diversions from the way we actually code objects in rebol ! I would like to ask to those interested in such a library if these diversions would be inappropriate to their coding style, taste, etc... rebol source code = [ ... ] 1. new class would be define like this : make-class 'class-name [ ... ] Inherited class would be define like this : make-class/from 'class-name [ ... ] super-class-name [ ... ] would look similar to the code we currently use in make object! [ ... ] 2. Object would be instanciated as : new-object-name: class-name/new I'm thinking about adding an automatic initiation method that would be call when instanciating an object ! What about a destroy method... 3. Type validation would be send as : object-name/type-of class-name 4. Within class declaration, methods would be define like this : method-name: func [value !refinement ref-value] [ ... ] However, during execution, refinement would be use as usual : method-name "a value" mathod-name/refinement "a value" "a ref-value" 5. Class within class would be declared as such make-class 'class-name [ sub-class-within-class-name: sub-class ] where sub-class would be previously declared. Upon creation of a new-object/new, all sub-objects would have new instance of sub-class by sending new to these sub-class. 6. Extremely specific use of self/method or self/value within class-method-declaration. self/method or self/property would refer to the instance method or property... self method or self property would refer to the class method or property... 7. Specific calling of super-class within methods... 8. Current Reserved words : [class, super, self, new, type-of] I've spent a lot of time on this, I hope some people are intersted in this kind of library... otherwise I may return to my other project ;) Note : the library has not been tested enough for a public release. also, it would requires some testing by people working daily with objects in rebol, mainly rebol gurus who could tell me if everything I'm doing is proper or not ;) and how it could be better... or if a guru would like to take up the project and make it better ! I'm open to suggestion ! Best, Chris