English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Patterns that evaluate
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-02-13 (22:03)
From: Jacques Carette <carette@m...>
Subject: Patterns that evaluate
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 ;-).


PS: I guess I had first-class patterns on the brain; Maple has them 
[under the misleadingly-named function "typematch"] (but that's 
cheating, I know) and W. Kahl's Pattern Matching Calculus allows it, and 
I wrote a joint paper with Wolfram describing a categorical semantics 
for the PMC.