From: Martin Jambon <martin.jambon@ens-lyon.org>
To: Jacques Le Normand <rathereasy@gmail.com>
Cc: caml-list caml-list <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] default arguments in classes
Date: Wed, 17 Jun 2009 00:34:33 +0200 [thread overview]
Message-ID: <4A381DF9.8060502@ens-lyon.org> (raw)
In-Reply-To: <f74178430906161412u6d60f8c2m80dd90f02b57aa7d@mail.gmail.com>
Jacques Le Normand wrote:
> Hello list,
> I'm trying to define a method with a default argument, but I keep
> getting an error. Here's the code:
>
> class foo =
> object (self)
> method bar ?(baz="moo") () =
> (new foo)#bar ~baz ()
> end
>
> and the error:
>
> The expression "new foo" has type foo but is used with type
> < bar : baz:string -> unit -> 'a; .. >
> Types for method bar are incompatible
>
> how do I fix this?
Adding type annotations often helps:
class foo =
object (self)
method bar ?(baz="moo") () : unit =
((new foo) # bar : ?baz:_ -> _) ~baz ()
end
Martin
--
http://mjambon.com/
prev parent reply other threads:[~2009-06-16 22:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-16 21:12 Jacques Le Normand
2009-06-16 22:06 ` [Caml-list] " Paolo Donadeo
2009-06-16 22:34 ` Martin Jambon [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=4A381DF9.8060502@ens-lyon.org \
--to=martin.jambon@ens-lyon.org \
--cc=caml-list@yquem.inria.fr \
--cc=rathereasy@gmail.com \
/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