From: Jacques GARRIGUE <garrigue@kurims.kyoto-u.ac.jp>
To: jgoerzen@complete.org
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Optional arguments in inherited methods
Date: Thu, 29 Apr 2004 07:48:06 +0900 (JST) [thread overview]
Message-ID: <20040429.074806.68548985.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <20040428194330.GB7949@excelhustler.com>
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
next prev parent reply other threads:[~2004-04-28 22:48 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
2004-04-28 22:48 ` Jacques GARRIGUE [this message]
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=20040429.074806.68548985.garrigue@kurims.kyoto-u.ac.jp \
--to=garrigue@kurims.kyoto-u.ac.jp \
--cc=caml-list@inria.fr \
--cc=jgoerzen@complete.org \
/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