caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Karl Zilles <zilles@1969.ws>
To: Nicolas Cannasse <warplayer@free.fr>
Cc: Lex Stein <stein@eecs.harvard.edu>, caml-list@inria.fr
Subject: Re: [Caml-list] polymorphic methods in objects?
Date: Wed, 04 Jun 2003 10:30:19 -0700	[thread overview]
Message-ID: <3EDE2CAB.4020801@1969.ws> (raw)
In-Reply-To: <002301c32a49$bef062b0$2413f9ca@WARP>

Nicolas Cannasse wrote:
> two ways of doing that :
> 
> first, having a parameterized object :
> 
> class ['a] my_object : object
>     method dummy_init : 'a -> unit
> end
> 
> But perhaps here you really want that any value passed to your object is ok.
> So you have to use a polymorphic method, which is not bound to the class
> type :
> 
> class my_object : object
>     method dummy_init : 'a . 'a -> unit
> end
> 
> This way, you cannot of course store the parameter into a field of my_object
> this it is not polymorphic.

The stuff Nicolas mentions is covered in sections 3.9 and 3.10 of the 
current manual.  You should probably read these sections, because use of 
polymorphic methods can sometimes require type constraints.

http://caml.inria.fr/ocaml/htmlman/manual005.html#ss:parameterized-classes
http://caml.inria.fr/ocaml/htmlman/manual005.html#ss:polymorphic-methods



-------------------
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:[~2003-06-04 17:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-04  3:07 Lex Stein
2003-06-04  3:31 ` Nicolas Cannasse
2003-06-04 17:30   ` Karl Zilles [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=3EDE2CAB.4020801@1969.ws \
    --to=zilles@1969.ws \
    --cc=caml-list@inria.fr \
    --cc=stein@eecs.harvard.edu \
    --cc=warplayer@free.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).