[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Corey O'Connor <coreyoconnor@g...> |
| Subject: | Re: [Caml-list] Heritage |
For something that provides the functionality of runtime inheritance
check out the Decorator pattern.
http://www.dofactory.com/Patterns/PatternDecorator.aspx
Essentially the deccorator pattern is like this:
* All decorators conform to the same interface of the object they are
decorating.
* Methods follow this pattern: (In C++)
type CMyDecorator::SomeMethod(args)
{
// Do some additional stuff
return mObjectBeingDecorated.SomeMethod(args);
}
The end result is you can add functionality to methods of an object at runtime.
Hope that helps,
-Corey O'Connor
On 9/15/05, David Baelde <david.baelde@gmail.com> wrote:
> Hi list,
>
> We're getting crazy with some design problem. We need to design a
> buffer object and be able to extend it with some features
> (lexing,color highlighting... yes we're working on an editor). Here's
> the problem.
>
> I'd like to have a class (or function) for every extension. For
> example be able to write
> new parsed (new lexed (new basic)). I.e. I would need the class:
>
> class lexed buf =
> object inherit buf method get_token = ... end
>
> It doesn't work cause inheritance is only from classes, not objects.
> But I want buf to be of any class (any super-class of buffer actually)
> but I don't want to coerce buf to type buffer, cause I want to keep
> extra methods if any were added.
>
> I'd like to know if there's any simple example of why
> object-inheritance is forbidden, and if any of you have an idea for
> that problem..
>
> Thanks.
> --
> David
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
--
-Corey O'Connor