From: Dario Teixeira <darioteixeira@yahoo.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Smells like duck-typing
Date: Thu, 18 Oct 2007 17:24:32 +0100 (BST) [thread overview]
Message-ID: <939878.37106.qm@web54604.mail.re2.yahoo.com> (raw)
In-Reply-To: <377673.31302.qm@web54602.mail.re2.yahoo.com>
Hi,
(This is a collective reply to all the issues that were raised by my
previous message; sorry if I don't answer each message individually).
I made the early "reverse inheritance" suggestion somewhat facetiously,
but judging from the replies, there was a certain amount of confusion
about what I meant.
I'll try to describe what I have in mind. I'll do it by modelling
the problem in an imaginary OCaml-derived language that features
"reverse inheritance". Please read on:
The "story" class is one that is fully defined. Think of it as a raw
block of marble from which the non-important pieces can be carved out.
To avoid confusion, let's call a class of this kind a "marble-class":
marble-class story (id, title, intro, body) =
object
method id: int = id
method title: string = title
method intro: string = intro
method body: string = body
end
Now, a "full_story" is one that is also fully defined. Taking as starting
point the "story" block-class previously defined, you don't need to carve
out anything to obtain a full_story:
marble-class full_story (id, title, intro, body) =
object
carves story (id, title, intro, body)
end
However, a "blurb_story" does introduce changes: it can be formed by
taking the original story as a starting point, and removing the "body"
chunk of marble. Note that I am using some new keywords: carves, removes,
and CARVED:
marble-class blurb_story (id, title, intro) =
object
carves story (id, title, intro, CARVED)
removes method body
end
Similarly, a "fresh_story" is a story without the "id" field:
marble-class fresh_story (title, intro, body)
object
carves story (CARVED, title, intro, body)
removes method id
end
Now, if you think in terms of traditional inheritance, a blurb_story
"B" is also a story "A", and so on (with OCaml's subtyping inheritance,
the semantics are a bit different, but let's not go there right now).
Therefore you would expect that any method that works on A should also
work on B. But here it's precisely the opposite: anything that works on
B should also work on A, but not the other way around. If the confusion
is purely linguistic, then let's not call it "reverse inheritance";
let's use "marble carving" instead. (Note that for these semantics
to be correct, then a carved-class is not allowed to add new methods,
but only to remove existing methods from the class it is carving).
Finally the big question: is this useful or even feasible to implement?
Probably not. But for the problem I have at hand, this is still the
modelling that best fits my mental picture of the relation between the
various story types.
Cheers,
Dario
___________________________________________________________
Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html
next prev parent reply other threads:[~2007-10-18 16:24 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-17 13:35 Dario Teixeira
2007-10-17 14:13 ` [Caml-list] " Arnaud Spiwack
2007-10-17 14:47 ` Dario Teixeira
2007-10-17 14:25 ` Daniel Bünzli
2007-10-17 15:03 ` skaller
2007-10-17 15:13 ` Dario Teixeira
2007-10-17 15:25 ` Arnaud Spiwack
2007-10-17 15:32 ` Daniel Bünzli
2007-10-17 16:21 ` Chris King
2007-10-18 7:28 ` Stefano Zacchiroli
2007-10-18 8:33 ` [ANN] pa_oo and pa_polymap for 3.10 (Re: [Caml-list] Smells like duck-typing) Jacques Garrigue
2007-10-17 16:57 ` [Caml-list] Smells like duck-typing skaller
2007-10-17 16:52 ` skaller
2007-10-17 16:59 ` Robert Fischer
2007-10-17 14:33 ` Chris King
2007-10-17 14:59 ` Dario Teixeira
2007-10-17 15:24 ` Vincent Aravantinos
2007-10-17 15:26 ` Zheng Li
2007-10-18 16:13 ` Zheng Li
2007-10-18 16:37 ` [Caml-list] " William D. Neumann
2007-10-19 0:58 ` Jacques Garrigue
2007-10-17 19:59 ` [Caml-list] " Richard Jones
2007-10-17 20:24 ` Dario Teixeira
2007-10-18 7:37 ` Stefano Zacchiroli
2007-10-18 10:31 ` Dario Teixeira
2007-10-18 10:37 ` Stefano Zacchiroli
2007-10-18 13:28 ` Robert Fischer
2007-10-18 14:10 ` Dario Teixeira
2007-10-18 14:18 ` Brian Hurt
2007-10-18 14:29 ` Arnaud Spiwack
2007-10-18 14:45 ` Brian Hurt
2007-10-18 15:02 ` Arnaud Spiwack
2007-10-18 15:07 ` Robert Fischer
2007-10-18 15:14 ` Arnaud Spiwack
2007-10-18 16:39 ` skaller
2007-10-18 16:49 ` Arnaud Spiwack
2007-10-18 17:47 ` skaller
2007-10-18 19:55 ` Robert Fischer
2007-10-18 16:22 ` skaller
2007-10-18 16:30 ` Dario Teixeira
2007-10-18 14:58 ` Robert Fischer
2007-10-18 15:11 ` William D. Neumann
2007-10-18 15:47 ` Loup Vaillant
2007-10-18 16:08 ` William D. Neumann
2007-10-19 13:08 ` Ed Keith
2007-10-18 16:24 ` Dario Teixeira [this message]
2007-10-18 16:35 ` Vincent Aravantinos
2007-10-18 16:43 ` Brian Hurt
2007-10-18 17:04 ` William D. Neumann
2007-10-18 17:05 ` Dario Teixeira
2007-10-18 17:22 ` Brian Hurt
2007-10-18 17:58 ` Dario Teixeira
2007-10-18 15:42 ` Vincent Aravantinos
[not found] <47161E3B.3060704@tsc.uc3m.es>
2007-10-17 15:01 ` Dario Teixeira
2007-10-17 20:20 ` Alain Frisch
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=939878.37106.qm@web54604.mail.re2.yahoo.com \
--to=darioteixeira@yahoo.com \
--cc=caml-list@yquem.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