caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Basile Starynkevitch <basile@starynkevitch.net>
To: Walter Cazzola <cazzola@dico.unimi.it>
Cc: OCaML Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] pattern matching on strings
Date: Wed, 14 Sep 2011 22:40:11 +0200	[thread overview]
Message-ID: <20110914224011.70c49bb251e84a4186a2b44d@starynkevitch.net> (raw)
In-Reply-To: <alpine.LFD.2.00.1109142210370.2647@surtur.dico.unimi.it>

On Wed, 14 Sep 2011 22:16:42 +0200 (CEST)
Walter Cazzola <cazzola@dico.unimi.it> 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} ***

  reply	other threads:[~2011-09-14 20:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-14 20:16 Walter Cazzola
2011-09-14 20:40 ` Basile Starynkevitch [this message]
2011-09-16 21:20   ` Richard W.M. Jones
2011-09-17  8:15     ` Basile Starynkevitch
2011-09-14 20:57 ` Philippe Veber
2011-09-14 21:44   ` Raphael Proust
2011-09-16 22:18     ` Philippe Veber
2011-09-14 21:14 ` Philippe Strauss

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110914224011.70c49bb251e84a4186a2b44d@starynkevitch.net \
    --to=basile@starynkevitch.net \
    --cc=caml-list@inria.fr \
    --cc=cazzola@dico.unimi.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).