* [Caml-list] syntax suggestion
@ 2013-04-27 7:18 rixed
2013-04-27 8:04 ` Gabriel Scherer
0 siblings, 1 reply; 2+ messages in thread
From: rixed @ 2013-04-27 7:18 UTC (permalink / raw)
To: caml-list
Wouldnt it be nice if, as a special form of the = operator,
"variable = pattern when condition" were equivalent to
"match variable with pattern when condition -> true | _ -> false" ?
So that one could easily check optional values for instance:
if variable = Some x when x > 15 then blabla
What do you think?
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] syntax suggestion
2013-04-27 7:18 [Caml-list] syntax suggestion rixed
@ 2013-04-27 8:04 ` Gabriel Scherer
0 siblings, 0 replies; 2+ messages in thread
From: Gabriel Scherer @ 2013-04-27 8:04 UTC (permalink / raw)
To: rixed; +Cc: caml-list
This is a subset of Richard Jones' "matches" syntax extension, turning
an pattern matching on 'a into a ('a -> bool) function:
if (matches Some x when x > 15) variable then ...
(The original extension did not handle "when", but it would be quite
easy to add.)
On Sat, Apr 27, 2013 at 9:18 AM, <rixed@happyleptic.org> wrote:
> Wouldnt it be nice if, as a special form of the = operator,
> "variable = pattern when condition" were equivalent to
> "match variable with pattern when condition -> true | _ -> false" ?
>
> So that one could easily check optional values for instance:
>
> if variable = Some x when x > 15 then blabla
>
> What do you think?
>
>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-04-27 8:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-27 7:18 [Caml-list] syntax suggestion rixed
2013-04-27 8:04 ` Gabriel Scherer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox