Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Syntax ideas for non-uniform memory (near/far etc)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-01-05 (20:18)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Syntax ideas for non-uniform memory (near/far etc)
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:

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).


Richard Jones
Red Hat