Browse thread
[Caml-list] Optional arguments in inherited methods
-
John Goerzen
-
james woodyatt
-
John Goerzen
- Jacques GARRIGUE
-
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: | Jacques GARRIGUE <garrigue@k...> |
| Subject: | Re: [Caml-list] Optional arguments in inherited methods |
From: John Goerzen <jgoerzen@complete.org> > Argh. Does OCaml's object system really not support adding additional > optional variables to subclass methods? No, it doesn't support that. Methods in subclasses must have exactly the same type as in the superclass (the types are unified during checking). So you are not even allowed to use a subtype of the original method type (which would be perfectly sound in theory) > That would be rather annoying if true. Unfortunate, but in the case of optional arguments the problem is not with typing but with how they are implemented: an optional argument of type [t] is actually a non-optional argument of type [t option]. They disappear automagically on application, but this means that None's are automatically inserted. So applying a function which has optional arguments is completely different from a function without them (even if the function call looks the same in your source code). Jacques Garrigue ------------------- 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