From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: caml-list@davidb.org
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Typing problem with polymorphic variants
Date: Wed, 02 Apr 2003 10:34:25 +0900 [thread overview]
Message-ID: <20030402103425U.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <20030401184428.GA895@opus.davidb.org>
From: David Brown <caml-list@davidb.org>
> I would apply the same question to the object system: why can a
> signature not hide methods of a class.
>
> Does making the signature more restrictive somehow hurt the type system?
>
> e.g.:
>
> class foo : object method baz : int end =
> object
> method baz = 5
> method bar = 2
> end
>
> gives:
>
> The class type object method bar : int method baz : int end
> is not matched by the class type object method baz : int end
> The public method bar cannot be hidden
Just consider now a variant on your example:
class foo : object method baz : int end =
object (self)
method baz = self#bar + 3
method bar = 2
end
class bar = object
inherit foo
method bar = "hello"
end
If you can forget the method bar, the class bar becomes typable.
However (new bar)#baz lead to computing ["hello" + 3] which is
unsound.
You can try to change the problem in many ways, but the conclusion is
that there is no way to allow the hiding of a public method without a
notion of generative types for objects or views. There is a paper by
Jerome Vouillon on the subject
http://www.pps.jussieu.fr/~vouillon/publi.html
Combining subsumption and binary methods: An object calculus with views.
Jacques Garrigue
-------------------
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
prev parent reply other threads:[~2003-04-02 1:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-01 17:34 Alessandro Baretta
2003-04-01 18:38 ` Ville-Pertti Keinonen
2003-04-01 17:56 ` Alessandro Baretta
2003-04-01 18:44 ` David Brown
2003-04-02 1:34 ` Jacques Garrigue [this message]
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=20030402103425U.garrigue@kurims.kyoto-u.ac.jp \
--to=garrigue@kurims.kyoto-u.ac.jp \
--cc=caml-list@davidb.org \
--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).