Browse thread
[Caml-list] Optional arguments in inherited methods
-
John Goerzen
-
james woodyatt
- John Goerzen
-
james woodyatt
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | John Goerzen <jgoerzen@c...> |
| Subject: | Re: [Caml-list] Optional arguments in inherited methods |
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