Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: "chris.danx" <chris.danx@ntlworld.com>
Cc: John Prevost <j.prevost@gmail.com>,
	Caml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Restricting Method Overriding/Redefinition in Subclass
Date: 19 Aug 2004 08:21:29 +1000	[thread overview]
Message-ID: <1092867689.29139.1414.camel@pelican.wigram> (raw)
In-Reply-To: <412345DC.5050206@ntlworld.com>

On Wed, 2004-08-18 at 22:04, chris.danx wrote:

>  Separating subtyping from subclassing is 
> something I'd read about (in the context of polymorphism and 
> subclassing) and thought was very useful. 

You aren't going far enough. Subtyping is a *semantic* notion.
Whether a class satisfies the 'is a' relation or not is the issue.

In Ocaml, if a class has a type which is not an *Ocaml* 
subtype of another it probably isn't a subtype semantically ***

The converse is not true. Just because Ocaml thinks your
class has a subtype of another classes type does NOT
mean it actually is a subtype -- you still need to check
the methods to make sure the 'is a' property holds. 
If you override some method and give it an incompatible
behaviour you don't have a subtype (you'll just get weird
bugs!)

*** It is possible to have a class which acts semantically
'as' another but is not ruled by Ocaml as a subtype.
A trivial example of this is when you have two methods
called 'size' in one class and 'length' in another
that do the same job -- but happen to be encoded with
distinct names. You'll have to use a wrapper to fix this
without invading one of the classes (and then probably
breaking something else).

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net



-------------------
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


  parent reply	other threads:[~2004-08-18 22:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-14  0:03 chris.danx
2004-08-14  7:38 ` skaller
2004-08-14 16:28   ` John Prevost
2004-08-14 17:17     ` skaller
2004-08-18 12:04     ` chris.danx
2004-08-18 19:47       ` John Prevost
2004-08-18 22:21       ` skaller [this message]
2004-08-16  4:58 Jeff Schultz

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=1092867689.29139.1414.camel@pelican.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=chris.danx@ntlworld.com \
    --cc=j.prevost@gmail.com \
    /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