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 (19:41)
From: Kuba Ober <ober.14@o...>
Subject: Syntax ideas for non-uniform memory (near/far etc)
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,

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

let print (s : rom) = ....
of type string -> unit

For those unfamiliar with embedded work, think 16-bit x86 with near/far 
pointers and whatnot.

I'm all ears for other ideas as to how it might be implemented. Any syntactic 
sugar to make it cleaner looking?

I presume that an extension of this idea is to have multi-faceted types, where 
each type is really a tuple of "types", such that some could be polymorphic 
and some not.

Say one wants to have a function which will work on data put anywhere:

let print (s : 'c, string) = ....

where 'c is the "storage class", here polymorphic, and string is the good old 

Of course none of this would use *the* OCaml compiler, I'm trying to write (or 
port, rather) my own.