[REBOL] Re: IS REBOL object oriented?
From: rpgwriter:ya:hoo at: 5-Jun-2002 17:01
--- Volker Nitsch <[nitsch-lists--netcologne--de]> wrote:
> Am Mittwoch, 5. Juni 2002 22:14 schrieb Christopher
> > --- 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
> > compared to, say, C++ is you can't overload
> > it also only features single inheritance, but
> > not so uncommon.
> 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.