From: John Goerzen <jgoerzen@complete.org>
To: james woodyatt <jhw@wetware.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Optional arguments in inherited methods
Date: Wed, 28 Apr 2004 14:43:30 -0500 [thread overview]
Message-ID: <20040428194330.GB7949@excelhustler.com> (raw)
In-Reply-To: <02C591A1-9935-11D8-BD03-000A958FF2FE@wetware.com>
On Wed, Apr 28, 2004 at 09:56:36AM -0700, james woodyatt wrote:
> method getdataf sname = <code here returns function>
>
> ...you wish the compiler to insure that the default values are used for
> each of the optional arguments in the [possibly partial] evaluation of
> the derived class method.
>
> Well? it doesn't. You have to define the derived class method in two
> parts.
Hmm. I worked around that problem but now I have a new one. From my
.mli file, I have this in my superclass:
method get: ?default:string -> string -> string -> string
and I wish to have this in my subclass:
method get: ?default:string -> ?raw:bool -> ?idepth:int ->
?extravars:(string, string) Hashtbl.t
-> string -> string -> string
Now, since labeled args are not positional, I would think that the
compiler should have no problem with adding new optional args, since a
call to the base class's method would remain completely valid as a call
to the subclass's method. However, I get this error:
The method get has type
?default:string ->
?raw:bool ->
?idepth:int ->
?extravars:(string, string) Hashtbl.t -> string -> string -> string
but is expected to have type ?default:string -> string -> string -> string
Argh. Does OCaml's object system really not support adding additional
optional variables to subclass methods?
That would be rather annoying if true.
-- John
-------------------
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
next prev parent reply other threads:[~2004-04-28 19:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-28 16:13 John Goerzen
2004-04-28 16:56 ` james woodyatt
2004-04-28 19:43 ` John Goerzen [this message]
2004-04-28 22:48 ` Jacques GARRIGUE
2004-04-29 8:11 ` Henri DF
2004-04-29 8:48 ` 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=20040428194330.GB7949@excelhustler.com \
--to=jgoerzen@complete.org \
--cc=caml-list@inria.fr \
--cc=jhw@wetware.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