Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Richard Jones <rich@annexia.org>
To: Kuba Ober <ober.14@osu.edu>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Syntax ideas for non-uniform memory (near/far etc)
Date: Sat, 5 Jan 2008 20:18:13 +0000	[thread overview]
Message-ID: <20080105201813.GA27306@annexia.org> (raw)
In-Reply-To: <200801051441.00892.ober.14@osu.edu>

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


      reply	other threads:[~2008-01-05 20:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-05 19:41 Kuba Ober
2008-01-05 20:18 ` Richard Jones [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080105201813.GA27306@annexia.org \
    --to=rich@annexia.org \
    --cc=caml-list@yquem.inria.fr \
    --cc=ober.14@osu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox