caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Chase <chase@world.std.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Catching exceptions into strings
Date: Tue, 11 Jun 2002 13:44:59 -0400	[thread overview]
Message-ID: <5.1.0.14.0.20020611133017.027fe7d8@pop.theWorld.com> (raw)
In-Reply-To: <20020611173726.A14277@pauillac.inria.fr>

At 05:37 PM 6/11/2002 +0200, Xavier Leroy wrote:
>> where it happens to be necessary, and optimizing it out when it is not?
>
>I'm more skeptical here.  I'm yet to see a practical compile-time
>analysis that can prove that an integer expression is not zero in any
>but the most trivial cases (the expression is a constant or a for-loop
>index). (By "integer", I mean machine integers with modulo arithmetic.)

Trivial is pretty common, and for-loop index is an important
common case.  A "constant propagation" lattice can also be a
good deal more interesting than just constants.  I've worked on a
compiler that propagated information about type inference, null/not,
relationship to various array bounds, positive/negative/zero/not,
and a friend and I have discussed the usefulness (not the feasibility,
which is dead-simple) of propagating information about set/cleared/smeared
bits.  It is plausible, if you are working in the absence of reflection,
that a compiler might infer the non-zero-ness of array elements and
object fields.  If, on the other hand, you are working in a world where
programs have reflective access to data, then all bets are off (as in,
once upon a time, and maybe still, the native code in java.lang.sql went
out and fiddled with the private fields of strings, and I know of people
at a Famous Computer Company who wrote native code that twiddled the private
fields of Java file-related classes in order to get a sort of poor man's
asynchronous I/O.).

I've also learned to be incredibly skeptical about
any programmer's assertion that "X cannot possibly happen", and
throwing an exception means that you can at least talk about what
happens when X does happen.  Just for instance, a server program can
be written to catch any exception at the "outside" of a service
thread, and report it both to the web page and the debug log, and
then continue running as before.  This is much better than the server
falling over and needing a restart.

One approach to this problem, though I don't know if anyone has
seriously tried it, would be to ask the programmer to supply the
missing proof steps, and if those steps connect the dots, then the
checks come out.  This does require a cleverer proof engine in the
compiler, but I'd trust that a lot more than just believing some
claim that I read in a comment or a build script.

And lastly, what does it cost to do the check?  Surely, you did not
omit the check in the name of efficiency (he says, smirking) without
first measuring the cost?  That would be (ahem) premature optimization,
which is well-known as the root of all evil.  :-)

David Chase


-------------------
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


  reply	other threads:[~2002-06-11 17:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-10 14:27 Gaurav Chanda
2002-06-10 15:07 ` Xavier Leroy
2002-06-10 21:57 ` Michael Vanier
2002-06-12  8:53   ` Xavier Leroy
2002-06-12  9:36     ` Michael Vanier
2002-06-17 12:48       ` Xavier Leroy
2002-06-17 16:10         ` Ken Rose
2002-06-11  9:23 ` Guillaume Valadon
2002-06-11 13:28   ` David Chase
2002-06-11 15:37     ` Xavier Leroy
2002-06-11 17:44       ` David Chase [this message]
2002-06-12  8:33         ` Xavier Leroy
2002-06-11 21:19       ` Michael Vanier
2002-06-14 21:23       ` John Carr
2002-06-17 12:31         ` Xavier Leroy
2002-06-17 21:08           ` John Carr

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=5.1.0.14.0.20020611133017.027fe7d8@pop.theWorld.com \
    --to=chase@world.std.com \
    --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).