From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: johan.baltie@wanadoo.fr
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Statically detecting arrays bound exceptions ?? (was: Universal Serializer)
Date: Wed, 17 Jul 2002 16:32:58 +0900 [thread overview]
Message-ID: <20020717163258S.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <20020717071424.M65430@wanadoo.fr>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: Text/Plain; charset=us-ascii, Size: 1914 bytes --]
From: "Johan Baltié" <johan.baltie@wanadoo.fr>
> > In the second case, you should propagate the information from the
> > assertion to the loop bound, and additionally treat swap as if it were
> > inlined (we know it is its only call context).
>
> No it's not such a mess. A subrange is a type. As ocaml is a bit
> strong on is types it solves itself the problem
OK, I should have been clearer about my basic assumption: I was
talking about what you can do _without_ modifying the typing.
Modifying the typing is a mess: if your bounds are no longer integers,
then how can you convert between them and integers, back and forth.
You could use subtyping in one direction, but there is no implicit
subtyping in ocaml, as this would badly break type inference.
> > And it's fragile:
> > if you move "swap" out of the function, then it might be used on any
> > array, and you have to do the bound check.
>
> If you move swap out of the function, in another one using another array, the
> type will change and a warning/error/check will occur if the types
> are incompatible.
No, I was just saying moving swap to the toplevel:
let swap arr i = ....
Supposing you use the original plain type, you are in trouble.
But it looks like you're just asking for dependent types, no less...
I think this discussion started on efficiency considerations;
my belief is that you can already already optimize a lot, without
using fancy type systems. Such type systems are not only hard to
implement (and mix with an existing type system); while they
certainly take bugs, they also get in your way when you get out of
their small understanding.
Cheers,
Jacques Garrigue
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2002-07-17 7:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-17 6:19 Johan Baltié
2002-07-17 6:46 ` Jacques Garrigue
2002-07-17 7:14 ` Johan Baltié
2002-07-17 7:32 ` Jacques Garrigue [this message]
2002-07-17 7:53 ` [Caml-list] Sub{range,type} (was: Statically detecting arrays bound exceptions ??) Johan Baltié
-- strict thread matches above, loose matches on Subject: below --
2002-07-08 19:53 [Caml-list] productivity improvement Oleg
[not found] ` <15657.61603.221054.289184@spike.artisan.com>
2002-07-09 4:43 ` [Caml-list] Universal Serializer (was: productivity improvement) Oleg
2002-07-09 7:59 ` Nicolas Cannasse
2002-07-10 16:06 ` John Max Skaller
2002-07-10 22:29 ` Michael Vanier
2002-07-12 12:41 ` John Max Skaller
2002-07-14 12:25 ` [Caml-list] Statically detecting arrays bound exceptions ?? (was: Universal Serializer) Berke Durak
2002-07-14 13:24 ` Alessandro Baretta
2002-07-15 8:23 ` Xavier Leroy
2002-07-15 8:39 ` Noel Welsh
2002-07-15 21:22 ` Oleg
2002-07-15 22:44 ` Michael Vanier
2002-07-16 6:43 ` Florian Hars
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=20020717163258S.garrigue@kurims.kyoto-u.ac.jp \
--to=garrigue@kurims.kyoto-u.ac.jp \
--cc=caml-list@inria.fr \
--cc=johan.baltie@wanadoo.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