caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: alex@baretta.com
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] What about polymorphic methods?
Date: Sat, 25 May 2002 12:55:30 +0900	[thread overview]
Message-ID: <20020525125530P.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <3CEF08ED.80407@baretta.com>

From: Alessandro Baretta <alex@baretta.com>

>      method left_iter : ('a -> 'b) -> 'b list
>      method right_iter : ('a -> 'c) -> 'c list
> 
> Is there any way, then, to define polymorphic versions of 
> the two iterators?

Indeed, iterators are one of the major reasons to have polymorphic
methods in ocaml (the other one being implicit subtyping of
arguments). They are already in CVS, and will be present in ocaml
3.05.

With the CVS version, you would have to write

   method left_iter : 'b. ('a -> 'b) -> 'b list = fun f -> ...
   method right_iter : 'b. ('a -> 'b) -> 'b list = fun f -> ...

Of course, 'b is no longer a parameter of the class.
Note that polymorphic methods can only be called on objects whose type
is (at least partially) known, so you may have to add a few extra type
annotations to your code.

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


  reply	other threads:[~2002-05-25  3:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-25  3:45 Alessandro Baretta
2002-05-25  3:55 ` Jacques Garrigue [this message]
2002-05-25  5:42   ` John Prevost
2002-05-27 19:10   ` Alessandro Baretta
2002-05-27 18:22     ` John Max Skaller
2002-05-30  0:02       ` Alessandro Baretta
2002-05-27 18:27     ` [Caml-list] Possible use for camlp4 John Max Skaller
2002-05-27 18:35       ` Alexander V. Voinov
2002-05-27 19:33       ` Daniel de Rauglaudre
2002-05-29 19:25         ` John Max Skaller
2002-05-30  2:42           ` Jacques Garrigue
2002-05-30  8:15           ` Daniel de Rauglaudre
2002-05-27 19:37       ` Daniel de Rauglaudre
2002-06-02  8:34   ` [Caml-list] What about polymorphic methods? Lauri Alanko
2002-06-03 23:57     ` Jacques Garrigue
2002-06-08  9:52   ` [Caml-list] What about polymorphic methods Alessandro Baretta
2002-06-10 10:13     ` Jacques Garrigue

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=20020525125530P.garrigue@kurims.kyoto-u.ac.jp \
    --to=garrigue@kurims.kyoto-u.ac.jp \
    --cc=alex@baretta.com \
    --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).