[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jon Harrop <jon@f...> |
| Subject: | Re: [Caml-list] Patterns that evaluate |
On Tuesday 13 February 2007 22:04, Jacques Carette wrote:
> I recently wrote some ocaml code which "worked", but not as I
> intended... The test cases I tried worked, but I should have tested
> harder. Apparently I was under the mistaken impression that OCaml's
> pattern-matching was more "first class"! So I wrote (in part):
>
> let buildsimp cast e f1 f2 = fun e1 -> fun e2 -> match (e1,e2) with
>
> | ({st = Some e}, _) -> e2
>
> and I expected it to work. Only a code review by a colleague 'found'
> this bug in my code.
>
> Question: would it be a difficult extension? This seemed so "natural",
> I just "used" the feature before it was quite there yet ;-).
F# just introduced active patterns, which does what you want AFAIK. Of course,
you must disambiguate that from the OCaml's current interpretation of the
above (binding "e").
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists