From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA04021; Sat, 1 May 2004 20:25:45 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA05948 for ; Sat, 1 May 2004 20:25:44 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from lavoro.terzarima.net (spc1-york1-5-0-cust44.leed.broadband.ntl.com [80.0.45.44]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i41IPhSH019731 for ; Sat, 1 May 2004 20:25:43 +0200 Message-ID: To: caml-list@inria.fr Subject: Re: [Caml-list] Reading a large text file From: Charles Forsyth Date: Sat, 1 May 2004 19:25:12 +0100 In-Reply-To: <20040501180508.GA16958@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4093EBA7.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 forsyth:01 forsyth:01 immutable:01 disadvantage:01 bug:01 appending:01 implemented:01 hash:01 ocaml:01 ocaml:01 mutable:01 lisp:01 lisp:01 penalty:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >>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