From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 322C5BC69 for ; Sat, 5 Jan 2008 21:18:18 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAMZ0f0dQRFuw/2dsb2JhbACpWg X-IronPort-AV: E=Sophos;i="4.24,249,1196636400"; d="scan'208";a="7469335" Received: from furbychan.cocan.org ([80.68.91.176]) by mail3-smtp-sop.national.inria.fr with ESMTP; 05 Jan 2008 21:18:17 +0100 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1JBFTC-0007GX-0Z; Sat, 05 Jan 2008 20:18:14 +0000 Date: Sat, 5 Jan 2008 20:18:13 +0000 To: Kuba Ober Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Syntax ideas for non-uniform memory (near/far etc) Message-ID: <20080105201813.GA27306@annexia.org> References: <200801051441.00892.ober.14@osu.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200801051441.00892.ober.14@osu.edu> User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Spam: no; 0.00; syntax:01 non-uniform:01 ocaml:01 syntax:01 non-uniform:01 implements:01 read-only:01 pointer:01 cleanest:98 rogoff:01 wrote:01 rec:01 caml-list:01 caml-list:01 functions:01 On Sat, Jan 05, 2008 at 02:41:00PM -0500, Kuba Ober wrote: > I'm trying to adapt Ocaml syntax to embedded uses. There, memory is often > non-uniform and variables can live in different areas, say near/far/rom. > > I was wondering what would be the "cleanest" syntax for that. I presume that > adding near/far/rom as keywords and using them similarly to "rec" would work, > e.g. > > let print rom s = ... (* prints a string with a rom address *) > > The truth is that "rom/near/far" is really part of the type, as if a > function has a parameter living say in rom then it won't take one in > ram. So maybe one could have [...] It sounds a bit like you need a phantom type. Have a look around 1/3 of the way down this message, where Brian Rogoff implements the "classic" read-only/read-write/write-only phantom types: http://caml.inria.fr/pub/ml-archives/caml-list/2001/09/081c77179ee2a3787233902a51633122.en.html Phantom types only ensure that (eg.) you can't write to a ROM location, or you can only use certain functions on a near pointer. They don't actually generate any extra code or overhead (which is, in a way, a good thing about them). Rich. -- Richard Jones Red Hat