caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Read-only arrays ?
Date: Wed, 11 Apr 2007 06:50:17 +0100	[thread overview]
Message-ID: <200704110650.17854.jon@ffconsultancy.com> (raw)
In-Reply-To: <20070411.143120.55511796.garrigue@math.nagoya-u.ac.jp>

On Wednesday 11 April 2007 06:31, Jacques Garrigue wrote:
> If your board is already abstract, why convert it to arrays?

Yes, the API is the problem and not the lack of immutable arrays. Just pull 
the array functions that you use into the Board module, e.g. Board.init. 
Essentially, you'll be coalescing an immutable array implementation with your 
Board module.

You may also want to add a "where" function that accepts a continuation and 
applies it to the board with one element changed, undoing the change upon 
return. I find that to be a useful idiom.

> This is actually the strongest argument against immutable arrays: they
> are just an abstraction over arrays, that you can easily make yourself
> when needed.

I disagree. Syntax is important enough that strings and arrays have 
abbreviated (and clearer) syntaxes for getting and setting elements in OCaml. 
You cannot add that to your own immutable array implementation (unless you 
use macros as well, in which case you've forked the language itself).

F# is very nice in this respect, allowing the a.[i] syntax to be overloaded so 
that strings, arrays, vectors, matrices, maps, hash tables and so on can all 
share the same syntax.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists


      reply	other threads:[~2007-04-11  5:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-10 21:03 David Teller
2007-04-10 21:35 ` [Caml-list] " Martin Jambon
2007-04-10 21:57   ` Harrison, John R
2007-04-10 23:12     ` Martin Jambon
2007-04-11  5:08       ` David Teller
2007-04-11  5:31         ` Jacques Garrigue
2007-04-11  5:50           ` Jon Harrop [this message]

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=200704110650.17854.jon@ffconsultancy.com \
    --to=jon@ffconsultancy.com \
    --cc=caml-list@yquem.inria.fr \
    /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).