Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Delegation based OO
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-03-23 (09:02)
From: Stefano Zacchiroli <zack@b...>
Subject: Re: [Caml-list] Delegation based OO
On Tue, Mar 23, 2004 at 10:14:02AM +0900, Jacques Garrigue wrote:
> Note however that one needs to know more clearly which methods are to
> be delegated, so I would rather favor a notation like:
>  class does_more an_object = object
>     delegate does_something to an_object
>     ...
>  end

Isn't enough to have a (closed) object type annotation for "an_object"?
In this way you would now exactly the signature of the object to which
you want to delegate without having to enumerate all of them.

I find Alex idea really cool, delegation is a widely used technique in
OO programming but at the same time is painful to use because you have
to write the pattern:

  method foo = delegate#foo
  method bar = delegate#bar

Having to write

  delegate foo to delegate
  delegate bar to delegate

is not a big improvement, whereas writing

  class type delegate_type =
      method foo: ...
      method bar: ...

  delegate delegate_type to an_object

would really be an improvement.


Stefano Zacchiroli -*- Computer Science PhD student @ Uny Bologna, Italy
zack@{,,} -%-
If there's any real truth it's that the entire multidimensional infinity
of the Universe is almost certainly being run by a bunch of maniacs. -!-

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: