caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Initializing default arguments
@ 2000-01-13 15:05 Markus Mottl
  2000-01-14  3:00 ` Jacques Garrigue
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Mottl @ 2000-01-13 15:05 UTC (permalink / raw)
  To: OCAML

Hello,

I just wondered about ways to get rid of definitions like

  let rec foo_aux init = ...
  let foo = foo_aux []

using labels and default arguments. There I found a problem with functions
like:

  let rec tautology ?(:vs = variables t) t = ...

It is not possible to reference arguments (here: 't') from default
arguments if they appear later in the function definition.  It is clear
that this would be problematic if the other argument also had a default
value and if it referenced the first value again (recursion).

However, I believe it should be always ok to use non-default arguments
regardless of order, because they are always already initialized.

The following does not work as intended

  let rec tautology t ?(:vs = variables t) = ...

because I would have to place further arguments after it so that the
default argument can be erased (e.g. by adding '()'). Although the latter
requirement is not really painful it is at least not as convenient as it
could be.

Is it possible to remove this restriction or are there further problems I
did not foresee?

Best regards,
Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-01-14  7:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-13 15:05 Initializing default arguments Markus Mottl
2000-01-14  3:00 ` Jacques Garrigue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).