On Wed, 14 Sep 2011 22:16:42 +0200 (CEST) Walter Cazzola <[email protected]> wrote: > > Does this mean that I can't write a function on strings by pattern > matching or is there something I don't know?
No, standard Ocaml 3.12 has no way of doing matching (in the sense of the match expression) on [the content of] Ocaml strings. (Of course, some library functions give you regexprs, scanf, ... etc, and you could match on constant Ocaml strings...). AFAIK, current Ocaml has no abstract matching, like the "views" in Wadler's sense (e.g. his POPL87 paper). Even in domain specific languages, abstract pattern matching is not easy to implement (shameless plug for my DSL11 http://eptcs.org/content.cgi?DSL2011 paper, see gcc-melt.org or http://arxiv.org/abs/1109.0779v1 ...) And there is a reason why you cannot match (in Ocaml) on the content of strings (or arrays). It won't be easy to implement efficiently (you would need to copy a substring or subarray when matching) Cheers. -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mine, sont seulement les miennes} *** -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
