caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pietro Abate <Pietro.Abate@pps.jussieu.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Arrays and private types
Date: Thu, 15 Mar 2012 12:04:27 +0100	[thread overview]
Message-ID: <20120315110427.GA12350@zed.irill.org> (raw)
In-Reply-To: <CAPFanBEfyWZRxFhi1jHj5bCVJJ3oztFa2pC2wV4Fn59b_p69Xw@mail.gmail.com>

On 15/03/12 00:00, Gabriel Scherer wrote:
> Here is a proposal:
>   https://gitorious.org/gasche-snippets/private-array-keys-type/blobs/master/private_array_key_types.ml
> 
> It works by using a functor to generate "fresh" private types for
> keys. Note that the arrays themselves are still polymorphic (no
> IntArray FloatArray etc.). The user still has to use the discipline to
> produce a new application of ArrayMake each time she wants to use a
> different kind of array: if she only does `module A = ArrayMake(struct
> end)` and then use `A` for everything, there will be no additional
> safety guarantee.

Thanks Gabriel, very nice solution. If I go this way, I guess there is
no way to access array elements using the usual a.(i) syntax (where i
= M.key i)... (I've noticed your cleaver use of private on the array
type to avoid using the normal array syntax on your private arrays).

Is this a problem I can solve using a camlp4 decorator ?

This seems a bit complicated as the a.(i) syntax will be context
dependent, that is, the same syntax used with two different array types
should be translated to different get/set calls... and at the camlp4
level I don't have access to type information... Ideally, instead of
changing all my array access calls, I'd like just to change the type
of my indexes such that all my generic ints will be replaced by
M.key of the appropriate type...

p

ps: please do not Cc me. I'm subscribed to the list.

  reply	other threads:[~2012-03-15 11:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-14 20:12 Pietro Abate
2012-03-14 23:00 ` Gabriel Scherer
2012-03-15 11:04   ` Pietro Abate [this message]
2012-03-15 13:18     ` Gabriel Scherer

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=20120315110427.GA12350@zed.irill.org \
    --to=pietro.abate@pps.jussieu.fr \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).