* Re: Pattern-matching destructors ?
@ 2007-10-16 16:16 Jeff Shaw
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Shaw @ 2007-10-16 16:16 UTC (permalink / raw)
To: caml-list
If you're matching against a record, you can omit the values you don't
care about. For instance:
type test = {a : int; b : int}
let testfun = function {a=x; b= y} when x=y -> "same" | {a=x} -> ("a is
" ^ string_of_int x);;
I'm not sure if this helps you but it's the first thing I thought off.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Pattern-matching destructors ?
@ 2007-10-16 15:20 David Teller
0 siblings, 0 replies; 2+ messages in thread
From: David Teller @ 2007-10-16 15:20 UTC (permalink / raw)
To: OCaml
Hi everyone,
I'm currently working on static analysis of JavaScript 2. For this, I
need to keep lots of informations in each node of my AST, including
things such as line/column (for better error messages), unique
identifier (for storing inferred information), etc. As things progress,
I fear that the number of such informations is growing prohibitive and
very much getting into the way of pattern-matching.
However, I do remember reading on this list a discussion regarding the
possibility of extending pattern-matching so as to allow matching
against user-defined criteria rather than constructors -- I'm afraid I
don't remember the name of these criteria, possibly "destructors" or
"queries".
As far as I remember this discussion, the feature was present in F# (or
at least planned), but not in OCaml. Could anyone tell me if things have
evolved on the OCaml side, perhaps with a little camlp4 magic ?
Thanks in advance,
David
--
David Teller ------------------------------------------
Security of Distributed Systems -----------------------
-- http://www.univ-orleans.fr/lifo/Members/David.Teller
----- Laboratoire d'Informatique Fondamentale d'Orleans
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-10-16 16:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-16 16:16 Pattern-matching destructors ? Jeff Shaw
-- strict thread matches above, loose matches on Subject: below --
2007-10-16 15:20 David Teller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox