From: John Prevost <j.prevost@cs.cmu.edu>
To: Alessandro Baretta <alex@baretta.com>
Cc: "Johan Baltié" <johan.baltie@wanadoo.fr>,
Ocaml <caml-list@inria.fr>,
"Daniel de Rauglaudre" <daniel.de_rauglaudre@inria.fr>
Subject: Re: [Caml-list] Recovering masked methods (with CamlP4?)
Date: 16 Jul 2002 09:32:08 -0400 (56.398 UMT) [thread overview]
Message-ID: <86u1mzu7c7.fsf@laurelin.dementia.org> (raw)
In-Reply-To: <3D33FE98.6000001@baretta.com>
>>>>> "ab" == Alessandro Baretta <alex@baretta.com> writes:
ab> In my code, class a = object method m = ... end Provides basic
ab> functionality common to all my inheritance hiearchy. Class a
ab> *also* defines the actual type of all my inheritance
ab> hieararchy, so I do not use subtyping at all; I use type
ab> *identity*. That's because I'm building a graph of objects of
ab> different classes, so all the objects in the graph need to
ab> have the same type. I only use inheritance because of code
ab> sharing. Now, class b = object inherit a ... end performs
ab> extensive personalizations to the functionality provided by
ab> class a, while always retaining the functionality of the
ab> parent, which is accessed by sending messages to
ab> super_a. Class var_b needs most of the functionality provided
ab> by b, with the sole exception of one method, which I call here
ab> m, which needs to be identical to the one defined in the root
ab> of the hierarchy.
Okay--let me rephrase what you just said to make sure I understand
correctly:
You have a class "a" which has a lot of common methods.
You have a class "b" which reuses and changes those.
You have a class "var_b" which is identical to "b" except that method
"m" is the same as "a".
If that is correct, I have no idea why you want to inherit the way
you've been talking about! Why in heaven's name wouldn't you just
write:
class a =
object
method m = ...
method m1 = ...
method m2 = ...
...
end
class var_b =
object
inherit a
method m1 = ...
method m2 = ...
...
end
class b =
object
inherit b
method m = ...
end
You've simply got the wrong ordering in your inheritance. There's
absolutely no need for more functionality to support accessing "older"
methods in this case. (I'd argue there's no need in any case.) And
again, even if method m had to be different in var_b, it would be
better to use an inherited class which has the features common to b
and var_b. In this case, that class is identical to b.
John.
-------------------
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
next prev parent reply other threads:[~2002-07-16 13:25 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-15 23:13 [Caml-list] Recovering masked methods Alessandro Baretta
2002-07-16 1:15 ` Jacques Garrigue
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 [this message]
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=86u1mzu7c7.fsf@laurelin.dementia.org \
--to=j.prevost@cs.cmu.edu \
--cc=alex@baretta.com \
--cc=caml-list@inria.fr \
--cc=daniel.de_rauglaudre@inria.fr \
--cc=johan.baltie@wanadoo.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