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

[REBOL] Re: IS REBOL object oriented?

From: nitsch-lists:netcologne at: 6-Jun-2002 5:34

Am Donnerstag, 6. Juni 2002 02:01 schrieb Christopher Dicely:
> --- Volker Nitsch <[nitsch-lists--netcologne--de]> wrote: > > Am Mittwoch, 5. Juni 2002 22:14 schrieb Christopher > > > > Dicely: > > > --- Abdel Belkasri <[belkasri--1stlegal--com]> wrote: > > > > Anton, > > > > > > > > 1- Can I create my own custom object? > > > > > > Sure. > > > > > > foo: make object! [ > > > . > > > . > > > . > > > ] > > > > > > That'll create an object. It works much like an > > > object in a "real" OO language -- it can have > > > data members, methods, etc. The big thing it > > > > misses > > > > > compared to, say, C++ is you can't overload > > > > operators; > > > > > it also only features single inheritance, but > > > > that's > > > > > not so uncommon. > > > > ===overloading > > > > if one codes like /view does, it works. > > that means implement vtables by hand (easy), > > and call the super-method by name. > > like (pseudocode) > > my-class: make super-class[ > > vtable: make vtable[ > > a-nice-tool: func[self arg1 arg2][ > > super-class/a-nice-tool self arg1 arg2 > > my-stuff self/var1 .. > > ] > > ] > > var1: var2: none > > ] > > my-object: make my-class[init-stuff] > > my-object/vtable/a-nice-tool my-object ;pass self > > by hand > > > > looks a bit ugly, but there are some kinds of > > semantic sugar possible. > > mostly becuase it hides quick in dialects :) > > Right, and you can use other tricks to do it > indirectly, too, I'm sure, but not as directly as the > operator/function overloading in, say, C++. >
this is no trick, its a pattern ;) c++ methods are hardwired. one can overload them, yes. but not redefine them dynamic. so use one class for data and another class with the method and switch the reference. modern frameworks use a handmade "vtable", exactly this way. like squeak/smalltalk with morph/player, java with one-method/no data listener classes, c++ with, well i forgot it. overloading is deprecated in ComponentPascal (heavy skilled unknown framework-builders), they choose the [ super-class/a-nice-tool self arg1 arg2 ] style. so why should rebol implement a more and more deprecated feature? ;)