Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Olivier Andrieu" <oandrieu@gmail.com>
To: "Jon Harrop" <jon@ffconsultancy.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Deconstructing optional arguments
Date: Fri, 11 Apr 2008 12:36:11 +0200	[thread overview]
Message-ID: <95513600804110336o2b715b2l7fdca4c3cd2727f2@mail.gmail.com> (raw)
In-Reply-To: <200804111024.16296.jon@ffconsultancy.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=GB2312, Size: 488 bytes --]

On Fri, Apr 11, 2008 at 11:24 AM, Jon Harrop <jon@ffconsultancy.com> wrote:
>
>  Is it possible to deconstruct an optional argument as you can with a labeled
>  argument:
>
>   let f ~p:(x,y) () = x - y
>
>  with something like:
>
>   let f ?(p=0,0):(x,y) () = x - y

sure, cf. the grammar in the refman
http://caml.inria.fr/pub/docs/manual-ocaml/expr.html

parameter	::=
        ...
 	¨O	 ? label-name : (  pattern  [: typexpr]  [= expr] )


let f ?p:(x,y=0,0) () = x - y

-- 
  Olivier

      parent reply	other threads:[~2008-04-11 10:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-11  9:24 Jon Harrop
2008-04-11 10:06 ` [Caml-list] " Alain Frisch
2008-04-11 10:36 ` Olivier Andrieu [this message]

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=95513600804110336o2b715b2l7fdca4c3cd2727f2@mail.gmail.com \
    --to=oandrieu@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=jon@ffconsultancy.com \
    /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