caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: alex@baretta.com
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Recovering masked methods
Date: Tue, 16 Jul 2002 10:15:20 +0900	[thread overview]
Message-ID: <20020716101520Q.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <3D335729.3020307@baretta.com>

From: Alessandro Baretta <alex@baretta.com>

> I have code similar to the following
> 
> class a =
> object (self)
>    method m = 1
>    method n = "Hello!"
> end
> 
> class b =
> object (self)
>    inherit a as super_a
>    method m = 2
> end
> 
> Now I would like to define a third class, inheriting from b. 
>   I need this class to be able to access the definition of 
> method m from class a, otherwise I would have to use "copy & 
> paste", which is contrary to my programmer's ethics.

You don't need to be too ethical about that.
What's so great about strong typing, is that it makes copy-paste work!

And you can always write

let a_m = 1
class a = ... method m = a_m ..

This way you can still share the code (but you need to pass private
methods by hand).

If you want to stay indide the object, you can also save the old
method to a private one:

class b = ... method private a_m = super_a#m ...

> Ideally, I would like to write
> 
> class c =
> object (self)
>    inherit b as super_b
> 
>    method m =
>      (* some_stuff *)
>      super_b # super_a # m
> end
> 
> Presently, this is not allowed. Is there any specific reason 
> for this? Could such a feature be implemented in the future?

OK, you want something like C++'s qualified calls?
There's no project to do that. Methods do not exist independently of
their class.
Another approach would be to provide views, as described by Jerome
Vouillon. That is, an object could keep some extra sets of methods in
an abstract way. But there's not project to implement that either.

Yet, it's not even clear such an ancestor call would make sense in
general.
Could you give some more compelling example requiring such a feature?

      Jacques
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2002-07-16  1:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-15 23:13 Alessandro Baretta
2002-07-16  1:15 ` Jacques Garrigue [this message]
2002-07-16  9:28   ` Alessandro Baretta
2002-07-16  9:48     ` Laurent Vibert
2002-07-16 10:08       ` Johan Baltié
2002-07-16 10:10       ` Alessandro Baretta
2002-07-16  9:59     ` Johan Baltié
2002-07-16 11:08       ` [Caml-list] Recovering masked methods (with CamlP4?) Alessandro Baretta
2002-07-16 11:32         ` Johan Baltié
2002-07-16 12:52           ` Alessandro Baretta
2002-07-16 12:26         ` Daniel de Rauglaudre
2002-07-16 12:54           ` Alessandro Baretta
2002-07-17  9:26             ` Daniel de Rauglaudre
2002-07-16 13:32         ` John Prevost
2002-07-16 13:35           ` John Prevost
2002-07-16 14:06           ` Alessandro Baretta
2002-07-16 14:15             ` Johan Baltié
2002-07-16 14:29               ` Alessandro Baretta
2002-11-11  9:20         ` Eray Ozkural
2002-07-16 10:45     ` [Caml-list] Recovering masked methods John Prevost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020716101520Q.garrigue@kurims.kyoto-u.ac.jp \
    --to=garrigue@kurims.kyoto-u.ac.jp \
    --cc=alex@baretta.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).