caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Richard Jones <rich@annexia.org>
To: Pascal Zimmer <Pascal.Zimmer@sophia.inria.fr>
Cc: Oliver Bandel <oliver@first.in-berlin.de>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] immutable Strings?
Date: Mon, 14 Mar 2005 12:57:29 +0000	[thread overview]
Message-ID: <20050314125728.GA17687@furbychan.cocan.org> (raw)
In-Reply-To: <423567E1.1030909@sophia.inria.fr>

On Mon, Mar 14, 2005 at 11:30:57AM +0100, Pascal Zimmer wrote:
> - you cannot use the shortcuts s.[i] and (^) anymore (this gets the code 
> less readable especially for the first one)

You can get the s.[i] shortcut by naming your module
'ImmString.String' (using a nested module in other words) and using
'open ImmString'.  However this has the further problem that you then
can no longer use mutable strings :-( although perhaps Oliver has
forsworn use of mutable strings, so this is an acceptable compromise
for him.

# module ImmString = struct
  module String = struct
  let get s i = prerr_endline "hello!"; 'c'   
  end
  end;;
module ImmString : sig module String : sig val get : 'a -> 'b -> char end end
# open ImmString;;
# "foo".[3];;
hello!
- : char = 'c'


Rich.

-- 
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com


  parent reply	other threads:[~2005-03-14 12:57 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
2005-03-14 12:57   ` Richard Jones [this message]
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=20050314125728.GA17687@furbychan.cocan.org \
    --to=rich@annexia.org \
    --cc=Pascal.Zimmer@sophia.inria.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=oliver@first.in-berlin.de \
    /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).