From: Alain Frisch <Alain.Frisch@inria.fr>
To: oleg@pobox.com
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Eliminating array bounds check
Date: Mon, 04 Sep 2006 09:42:00 +0200 [thread overview]
Message-ID: <44FBD8C8.6000307@inria.fr> (raw)
In-Reply-To: <44FBD432.8030602@inria.fr>
Alain Frisch wrote:
> What about making GenT a functor and passing it unnamed structures as
> arguments? (Ok, you must then trust the client not to apply GenT with
> named structures.)
Actually, GenT should be a functor anyway, since the abstract types in
the resulting structure must encode invariants which depends on the
(length of the) array. Unfortunaly, you cannot make a polymorphic
functor such as:
module GenT(A : sig val a : 'a array end) ...
As a work-around, you can take only the length of the array as an argument:
module TrustedKernel(L: sig val len: int end) : sig
type 'a barray
type bindex
val unbi : bindex -> int
type bindexL
type bindexH
...
end = struct
let brand a =
assert(Array.length a = L.len);
(a,0,L.len - 1)
end
On the one hand, this adds one run-time check, but on the other hand it
makes the abstract index types depend only on the length (so the trusted
kernel could be used in algorithms which work with several arrays of the
same size simultaneously).
-- Alain
next prev parent reply other threads:[~2006-09-04 7:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-04 1:00 oleg
2006-09-04 7:22 ` [Caml-list] " Alain Frisch
2006-09-04 7:42 ` Alain Frisch [this message]
2006-09-06 5:03 ` oleg
2006-09-06 5:15 ` Jonathan Roewen
2006-09-07 9:48 ` oleg
2006-09-04 9:43 ` skaller
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=44FBD8C8.6000307@inria.fr \
--to=alain.frisch@inria.fr \
--cc=caml-list@inria.fr \
--cc=oleg@pobox.com \
/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