From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p8EKeNmP003193 for ; Wed, 14 Sep 2011 22:40:23 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EABgQcU7DDgCO/2dsb2JhbABBp0d5gVMBAQU6HCMQCxguOR4GE4d5ArVehm4EnU2HGQ X-IronPort-AV: E=Sophos;i="4.68,382,1312149600"; d="scan'208";a="119855860" Received: from 195-14-0-142.nuxit.net (HELO de558.ispfr.net) ([195.14.0.142]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 14 Sep 2011 22:40:18 +0200 Received: from ours.starynkevitch.net ([213.41.244.95] helo=glinka.lesours) by de558.ispfr.net with smtp (Exim 4.72) (envelope-from ) id 1R3wFl-0002Xd-88; Wed, 14 Sep 2011 22:40:17 +0200 Date: Wed, 14 Sep 2011 22:40:11 +0200 From: Basile Starynkevitch To: Walter Cazzola Cc: OCaML Mailing List Message-Id: <20110914224011.70c49bb251e84a4186a2b44d@starynkevitch.net> In-Reply-To: References: X-Mailer: Sylpheed 3.2.0beta3 (GTK+ 2.24.6; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] pattern matching on strings On Wed, 14 Sep 2011 22:16:42 +0200 (CEST) Walter Cazzola 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: basilestarynkevitchnet mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mine, sont seulement les miennes} ***