caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Charles Forsyth <forsyth@terzarima.net>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Reading a large text file
Date: Sat, 1 May 2004 19:25:12 +0100	[thread overview]
Message-ID: <a8d30e586b783b9aa520f2194fef6b63@terzarima.net> (raw)
In-Reply-To: <20040501180508.GA16958@redhat.com>

>>The short answer is no, because in OCaml (unlike in LISP) lists are
>>immutable.  In LISP terminology, there's no way to 'set cdr' on an
>>OCaml 'cons structure'.  The disadvantage to this is that you can't do
>>certain destructive operations on lists, like you can so easily in
>>LISP.  The advantage is that you can't do certain destructive
>>operations on lists!  In other words, your code is more likely to be
>>bug free.

the concurrent programming language Limbo does much the same,
and has a similar penalty for appending to a list.  nevertheless, it has
advantages as you say, and i thought i'd add that the property
turns out to be quite helpful in concurrent programs, because you
can pass another process the current value of a list (for instance by sending
it on a channel) and be sure it always sees the `right' value.
i've found it particularly useful for lock-free concurrent access to caches
implemented by hash tables (array of list of T), when the cache
acts as a hint (as for instance in DNS implementation).
as you say, you can always program a mutable list when you need one.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2004-05-01 18:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-28 15:28 André Luiz Moura
2004-04-28 16:28 ` Richard Jones
2004-05-01 14:03 ` Brian Hurt
2004-05-01 15:43   ` Rahul Siddharthan
2004-05-01 16:00     ` [Caml-list] [OcamlDoc] langage support sejourne kevin
2004-05-14  7:15       ` Maxence Guesdon
2004-05-01 18:05     ` [Caml-list] Reading a large text file Richard Jones
2004-05-01 18:25       ` Charles Forsyth [this message]
2004-05-01 19:25       ` skaller
2004-05-01 19:51         ` Alain.Frisch
2004-05-01 20:40           ` skaller
2004-05-01 21:11             ` [Caml-list] Private types skaller
2004-05-01 21:33             ` [Caml-list] Reading a large text file Alain.Frisch
2004-05-17  5:28   ` Eric Stokes

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=a8d30e586b783b9aa520f2194fef6b63@terzarima.net \
    --to=forsyth@terzarima.net \
    --cc=caml-list@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).