From: Didier.Remy@inria.fr (Didier Remy)
To: monniaux@clipper.ens.fr (David Monniaux)
Cc: caml-list@inria.fr
Subject: Re: polymorphic methods in O'Caml (fwd)
Date: Mon, 26 Jan 1998 16:40:23 +0100 (MET) [thread overview]
Message-ID: <199801261540.QAA04729@pauillac.inria.fr> (raw)
In-Reply-To: <no.id> from David Monniaux at "Jan 22, 98 06:57:10 pm"
> [ J'aimerais des methodes polymorphes dans le systeme d'objets. ]
C'est possible, mais cela reste a implementer.
> The problem I have is the following: I have methods that can be invoked on
> container widgets to add a widget into them. As methods can be
> polymorphic, and more specifically can't have a parameter of type
> #someclass, use of those methods has to include a cast onto the type
> "widget". This is inelegant (watch for the (xxx :> widget) expressions in
> the sample code included).
We are aware of this problem. This is one of the (several) reasons that
motivated our investigation of first-class polymophism in ML [1]. Here, we
show that there is no theoretical problem at all. Technically, this requires
to trace some form of type sharing analogous to the one used for object type
aliases in O'Caml. In practive, it would provide polymorphic methods in O'Caml
in a quite simple way.
> Therefore, I'd like polymorphic methods to be implemented (even if it
> needs some explicit type declaration).
To get a polymophic method you would need to explicitly give its
(polymorphic) type in the class where it is defined.
Types of objects with polymophic methods would be inferred, but you would
also be required to explicitly write them when the context would not provide
sufficient type constraints,
This would not affect at all classes or objects that only use monomorphic
methods.
> Is there any reason why this couldn't be done?
We should certainly add this feature in some future version of O'Caml, but
nothing has been done yet.
--Didier.
[1] Extending ML with Semi-Explicit Higher-Order Polymorphism. Jacques
Garrigue and Didier Rémy. In International Symposium on Theoretical Aspects
of Computer Software, volume 1281 of Lecture Notes in Computer Science,
pages 20--46. Springer, September 1997. URL
http://pauillac.inria.fr/~remy/publications.html
next parent reply other threads:[~1998-01-28 12:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <no.id>
1998-01-26 15:40 ` Didier Remy [this message]
1999-01-16 18:58 ` subtyping and inheritance - correction Markus Mottl
1998-01-22 17:57 polymorphic methods in O'Caml (fwd) David Monniaux
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=199801261540.QAA04729@pauillac.inria.fr \
--to=didier.remy@inria.fr \
--cc=caml-list@inria.fr \
--cc=monniaux@clipper.ens.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