From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA07136 for caml-redistribution; Fri, 24 Dec 1999 11:54:04 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA25140 for ; Fri, 24 Dec 1999 11:10:37 +0100 (MET) Received: from isil.maya.com (HOPKINS.PC.CS.CMU.EDU [128.2.215.35]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id LAA06881 for ; Fri, 24 Dec 1999 11:10:30 +0100 (MET) Received: (from prevost@localhost) by isil.maya.com (8.9.3/8.9.3) id FAA01439; Fri, 24 Dec 1999 05:02:42 -0500 X-Authentication-Warning: isil.maya.com: prevost set sender to prevost@maya.com using -f Sender: weis To: caml-list@inria.fr Subject: Region thoughts From: John Prevost Date: 24 Dec 1999 05:02:42 -0500 Message-ID: <87iu1or70d.fsf@isil.maya.com> User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii I've finished an implementation of all the parts necessary for regions and mmaping. But the talk of using unsafe string operations and types to encode access control keeps me from releasing it to the world. :) Types seem good, and I think I'll do that no matter what. So the remaining question is whether there should be "region" primitives or if the unsafe string operations are sufficient. The only thing that unsafe string access *doesn't* seem to get me is a finalizer. One possibility is that I define things this way: type scary_c_function type 'a region = scary_c_function * int * string val get : #readable region -> int -> char val set : #writable region -> int -> char -> unit let get (_,l,r) i = if i >= l then raise ... else String.unsafe_get r i let set (_,l,r) i x = if i >= l then raise ... else String.unsafe_set r i x This way the definition of region includes the fact that there's this opaque scary value at the beginning of it, and C things to allocate regions can then use the finalized block tag and still (I think) interact with this code. (Which code should be pretty close to being the same as my cmmgen.ml stuff.) And the unsafe versions: let unsafe_get (_,_,r) i = String.unsafe_get r i let unsafe_set (_,_,r) i x = String.unsafe_set r i x Sound like a good course of action? How much CPU will I waste with my tuple access? (I assume no more than with my cmm code which was doing the same, but one does wonder.) If I do: f (Region.unsafe_get r 5) (Region.unsafe_get r 10) is the repeated decomposation of the tuple likely to be optimized away after inlining? (Not really *that* important to this discussion, I'm just interested. :) John.