Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Chris Hecker <checker@d6.com>
To: caml-list@inria.fr
Subject: [Caml-list] optional arguments and unification
Date: Tue, 03 Jun 2003 19:58:19 -0700	[thread overview]
Message-ID: <4.3.2.7.2.20030603195340.032a40e0@localhost> (raw)


I'm not sure I'm using the term "unification" properly, but here's the 
situation:

let f ?opt x = x + 1
let g x = x + 1
let h = if true then f else g

This expression has type int -> int but is here used with type
   ?opt:'a -> int -> int

So you have to do this:

let h = if true then f ?opt:None else g

Which is kinda ugly and goes against the "spirit" of optional arguments, I 
think.  Would it be possible to have a rule that says "if two types need to 
be unified and the only thing standing in the way are unspecified optional 
arguments then the compiler will default them automatically"?  Or does that 
lead to something unsound?

Chris

-------------------
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


             reply	other threads:[~2003-06-04  2:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-04  2:58 Chris Hecker [this message]
2003-06-04  3:23 ` Eric C. Cooper

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=4.3.2.7.2.20030603195340.032a40e0@localhost \
    --to=checker@d6.com \
    --cc=caml-list@inria.fr \
    /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