caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <mottl@miss.wu-wien.ac.at>
To: hayden@pa.dec.com (Mark Hayden)
Cc: caml-list@inria.fr (OCAML)
Subject: Re: Immutable arrays (modest Feature request)
Date: Fri, 14 Jan 2000 21:29:55 +0100 (MET)	[thread overview]
Message-ID: <200001142029.VAA15875@miss.wu-wien.ac.at> (raw)
In-Reply-To: <200001141809.KAA04904@src-mail.pa.dec.com> from "Mark Hayden" at Jan 14, 2000 10:09:44 AM

> You can write your own immutable arrays in Ocaml.
> See for instance util/arrayf.{ml,mli} in Ensemble,
> which is an implementation of functional arrays.
> 
>   http://www.cs.cornell.edu/Info/Projects/Ensemble/
> 
> Of course, there is no syntactic sugar for the
> constructors and Array.get operation.

Although, to my knowledge, you cannot use the syntactic sugar for
constructors, you can indeed have it for the "Array.get" and "Array.set"
operation:

What OCaml actually does when translating "ar.(i)" is that it calls
"Array.get ar i", where "Array" may be bound to any module you want.
When the flag "-unsafe" is specified to the compiler, it will use
"Array.unsafe_get ar i" instead. The same applies to "Array.set" and
"Array.unsafe_set". As long as you provide for both implementations,
there should be no problems.

However, it might then become difficult to use the standard arrays, because
you would have to rebind them to "Array" again each time you need them. But
be aware that modules can also be rebound locally as in:

  let foo n =
    let module Array = StdArray in
    ...

If you need more details on this, read the README in my distribution of
automatically resizing arrays on:

  http://miss.wu-wien.ac.at/~mottl/ocaml_sources/res/README

Regards,
Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl




  reply	other threads:[~2000-01-16 21:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <pfitzen@informatik.uni-tuebingen.de>
2000-01-13 19:45 ` Juergen Pfitzenmaier
2000-01-14 18:09   ` Mark Hayden
2000-01-14 20:29     ` Markus Mottl [this message]
2000-01-12 15:45 Thorsten Ohl
2000-01-12 22:06 ` Pierre Weis
2000-01-12 22:35   ` Norman Ramsey

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=200001142029.VAA15875@miss.wu-wien.ac.at \
    --to=mottl@miss.wu-wien.ac.at \
    --cc=caml-list@inria.fr \
    --cc=hayden@pa.dec.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;
as well as URLs for NNTP newsgroup(s).