caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Hurt <bhurt@janestcapital.com>
To: Arnaud Spiwack <aspiwack@lix.polytechnique.fr>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Smells like duck-typing
Date: Thu, 18 Oct 2007 10:45:59 -0400	[thread overview]
Message-ID: <471771A7.3010402@janestcapital.com> (raw)
In-Reply-To: <47176DB6.7090700@lix.polytechnique.fr>

Arnaud Spiwack wrote:

> Brian Hurt a écrit :
>
>> Dario Teixeira wrote:
>>
>>> Hi,
>>>
>>>  
>>>
>>>> That seems backwards from the way OO inheritance is supposed to 
>>>> work.  You don't go from a more feature-rich case to a less 
>>>> feature-rich case -- it's the other way around.
>>>>     
>>>
>>>
>>> Of course it is -- that is precisely why inheritance is the wrong
>>> formalism for my problem!  What I need is a "reverse inheritance"
>>> formalism, where a fully defined data structure sits at the root,
>>> and whose descendants are PRUNED versions of the parent.
>>>   
>>
>> The problem with this is that it violates one of the assumptions of 
>> typing, that if type A is (also) a type B, than anywhere you can use 
>> a type B, you can also use a type A.  This isn't an assumption 
>> limited to object oriented languages.  And this isn't true in your 
>> example- if type A is lacking members type B has, then it's possible 
>> to write situations where a "real" type B can be used, but not a type 
>> A- just use a field of type B that type A doesn't have.
>>
>> I think I'd recommend rethinking your approach to the problem.
>
> Well, what he is suggesting is to be able to derive a supertype A 
> given a type B. This is not fundamentaly incorrect. However I fail to 
> find any reasoning where it is made use of, in usual mathematics. So I 
> am, personnally, a bit puzzled by the suggestion, unable to say if it 
> might make sense or not (method exclusion is natural in the setting of 
> incomplete objets or traits, but it doesn't fit the situation very 
> much, since it usually produces something that requires to be completed).

Saying that A is a supertype of B is the equivelent of saying B is a 
subtype of A.  Same relation, different direction.  In OO lingo, how 
they say "B is a subtype of A" is that "B inherits from (is a subclass 
of) A".

In either case, while all B's are A's, not all A's are B's.  What he 
wants is a case where not all A's are B's, but because of the magic 
mindreading feature of the language (in conjunction with the DWIM 
feature of the hardware), you can treat all A's as B's, with the system 
magically filling in the missing values and methods.  This is what the 
mind reading is needed for- to know how to fill in the missing values.

I will note that Ocaml's row-level polymorphism allows you to invent new 
supertypes of a given subtype as needed (a real nice feature, IMHO).  
But what he's asking for is fundamentally nonsensical.

Brian


  reply	other threads:[~2007-10-18 14:46 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 [this message]
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
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=471771A7.3010402@janestcapital.com \
    --to=bhurt@janestcapital.com \
    --cc=aspiwack@lix.polytechnique.fr \
    --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;
as well as URLs for NNTP newsgroup(s).