caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <gerd@gerd-stolpmann.de>
To: wester@ilt.fhg.de, caml-list@inria.fr
Subject: Re: [Caml-list] classes and labels
Date: Tue, 20 Mar 2001 23:11:48 +0100	[thread overview]
Message-ID: <01032023143802.05414@ice> (raw)
In-Reply-To: <200103201502.QAA27766@ilt.fhg.de>

On Tue, 20 Mar 2001, wester@ilt.fhg.de wrote:
>Hi,
>
>I have the class definition:
>
># class myclass ?(n=0) () =
>  object  
>   val nn = n;
>   method get_nn = nn
>   method clone (na: int) = let (mc: myclass) = new myclass ~n:na () in mc;
>end;;
> 
>that produces the following error message in the toplevel:
>
>          Characters 5-153:
>The expression "new myclass" has type ?n:int -> unit -> myclass
>but is used with type int -> unit -> myclass
>
>Can sombody tell what is wrong with my class definition?

Nothing. It is a restriction of O'Caml 3.00. Your class definition works fine 
in 3.01. If you cannot upgrade, this is the workaround:

# class myclass ?(n=0) () =
  object  
   val nn = n;
   method get_nn = nn
   method clone (na: int) = 
     let (mc: myclass) = new myclass ?n:(Some na) () in mc; 
  end;;

Gerd
-- 
----------------------------------------------------------------------------
Gerd Stolpmann      Telefon: +49 6151 997705 (privat)
Viktoriastr. 100             
64293 Darmstadt     EMail:   gerd@gerd-stolpmann.de
Germany                     
----------------------------------------------------------------------------
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


  reply	other threads:[~2001-03-22  8:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-20 15:02 wester
2001-03-20 22:11 ` Gerd Stolpmann [this message]
2001-03-21  0:06 ` 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=01032023143802.05414@ice \
    --to=gerd@gerd-stolpmann.de \
    --cc=caml-list@inria.fr \
    --cc=wester@ilt.fhg.de \
    /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).