--- Volker Nitsch <[EMAIL PROTECTED]> wrote: > Am Mittwoch, 5. Juni 2002 22:14 schrieb Christopher > Dicely: > > --- Abdel Belkasri <[EMAIL PROTECTED]> 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++. > > ===multiple inheritance > > proto1: context[a1: b1: none] > proto2: context[a2: b2: none] > my-object: make make proto1 proto2 [my-var: none] > probe my-object > > make object! [ > a1: none > b1: none > a2: none > b2: none > my-var: none > ] Huh. Never thought of that. Nifty-cool, though. __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with "unsubscribe" in the subject, without the quotes.
