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 PAA11921; Sat, 31 Jul 2004 15:47:55 +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 PAA09376 for ; Sat, 31 Jul 2004 15:47:54 +0200 (MET DST) Received: from ptb-relay02.plus.net (ptb-relay02.plus.net [212.159.14.213]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i6VDlrSH015586 for ; Sat, 31 Jul 2004 15:47:54 +0200 Received: from [80.229.56.224] (helo=chetara) by ptb-relay02.plus.net with esmtp (Exim) id 1BquDJ-0003KD-Gq for caml-list@inria.fr; Sat, 31 Jul 2004 13:47:53 +0000 From: Jon Harrop To: caml-list@inria.fr Subject: Re: [Caml-list] const equivalent for mutable types? Date: Sat, 31 Jul 2004 14:44:56 +0100 User-Agent: KMail/1.6.2 References: <410B5EBD.6060800@cgorski.org> <20040731103412.GA11964@fichte.ai.univie.ac.at> In-Reply-To: <20040731103412.GA11964@fichte.ai.univie.ac.at> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200407311444.56864.jon@jdh30.plus.com> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 410BA309.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 const:01 2004:99 val:01 incr:01 val:01 decr:01 'rw:99 invokes:01 arrays:01 ocaml:01 ocaml:01 mutable:01 mutable:01 phantom:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Saturday 31 July 2004 11:34, Markus Mottl wrote: > ... > val incr : (int, [> `W ]) t -> unit > val decr : (int, [> `W ]) t -> unit Should these both be [`R|`W]? > The phantom variable is 'rw. When creating references, it can be any > of `R (for reading) and `T (for writing). Do you mean `W for writing? That's very interesting. So a phantom type is a type which you stick in to dupe the type system into doing something for you? Is there a good reference on those? I seem to remember a thread about their utility in porting the STL to ocaml but that was before I had ever used OCaml... And this const-alternative is useful when dealing with large records which have mostly constant but some mutable entries because handling such records invokes a lot of copying? But, say, arrays are passed by reference so this wouldn't provide much of a performance advantage, is that right? Incidentally, does anyone have a functional array implementation (which doesn't suck ;-)? Cheers, Jon. ------------------- 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