From: Pascal Zimmer <Pascal.Zimmer@sophia.inria.fr>
To: Jon Harrop <jon@ffconsultancy.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] immutable Strings?
Date: Mon, 14 Mar 2005 12:15:59 +0100 [thread overview]
Message-ID: <4235726F.3020403@sophia.inria.fr> (raw)
In-Reply-To: <200503141041.34682.jon@ffconsultancy.com>
Jon Harrop wrote:
> On Monday 14 March 2005 10:30, Pascal Zimmer wrote:
>
>>The bad points:
>>- you cannot use the shortcuts s.[i] and (^) anymore (this gets the code
>>less readable especially for the first one)
>>- you have to make a copy when creating an immutable string; if you were
>>not planning to keep the original string to modify it, this copy is in
>>fact useless
>
>
> Do you not also lose the ability to do pattern matching and to use all of the
> existing string-based functionality (e.g. the Str module)?
>
Yes, indeed, this is true for pattern matching. You have to replace it
with comparisons.
For functions that use strings, you have to add a new version in your
module, i.e. for every function
Lib.f : ... -> string -> ...
using strings that you want to use on immutable strings, all you have to
do is add the lines:
val f : ... -> t -> ...
let f = Lib.f
in module type and implementation respectively (see for example
print_string in my previous post), and use ImmString.f instead of Lib.f.
I have to admit this can get painful if you have to use a lot of them...
Pascal
next prev parent reply other threads:[~2005-03-14 11:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-12 20:50 Oliver Bandel
2005-03-14 10:30 ` [Caml-list] " Pascal Zimmer
2005-03-14 10:41 ` Jon Harrop
2005-03-14 11:15 ` Pascal Zimmer [this message]
2005-03-14 12:57 ` Richard Jones
2005-03-14 13:01 ` Richard Jones
2005-03-15 2:13 ` Jacques Garrigue
2005-03-15 8:09 ` Oliver Bandel
2005-03-15 8:40 ` Oliver Bandel
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=4235726F.3020403@sophia.inria.fr \
--to=pascal.zimmer@sophia.inria.fr \
--cc=caml-list@yquem.inria.fr \
--cc=jon@ffconsultancy.com \
/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