From: Eijiro Sumii <sumii@saul.cis.upenn.edu>
To: caml-list@inria.fr
Cc: sumii@saul.cis.upenn.edu
Subject: RE: reference initialization
Date: Mon, 15 May 2000 05:36:06 -0400 [thread overview]
Message-ID: <20000515053606J.sumii@saul.cis.upenn.edu> (raw)
In-Reply-To: <Pine.GSO.4.21.0005121605250.27709-100000@gatekeeper.ececs.uc.edu>
> Yes, in theory, it requires null check at every use. However,
> I assume that a marjority of such null checks can be readily
> eliminated using flow analysis,
I'm afraid that this is not so easy, especially under separate
compilation. For example, if we want to separately-compile a function
like "fun ref x -> !x + 1" (in the ocaml syntax), and if x could be
null, then the null check elimination would be hard. Such situations
seem ubiquitous in practice.
On the other hand, ML types work as an interface to specify whether x
is always initialized ("int ref") or not ("int option ref"). And
static typing enforces such a protocol between modules.
> Note that Java is imperative, which makes flow analysis easier
> (compared to ML).
I wonder how flow analysis can be easier in Java than in ML. While ML
has higher-order functions, Java has inner classes.
> A common saying is that a program is made safer if references
> are always initialized. I find this is contrary to the truth.
> In this case, a program is made safer if you insert run-time
> checks (and rely on a compiler to remove redundant checks)
>
> If I use 'get' and 'set', is there a compiler to eliminate such
> checks (i.e., after 'set', 'get' should do no tag checking)?
>
> Yes, ML allows the programmer to tag values (using option
> types) and thus shifts the burden to the programmer. In Java,
> this is done automatically (and we can rely on a compiler to
> remove redundant null checks).
ML could also do it automatically, by analyzing whether a value of an
"option" type always has the "Some" tag. The analysis would be
similar to standard flow analyses or type-based analyses.
// Eijiro Sumii <sumii@saul.cis.upenn.edu>
//
// currently visiting: Department of Computer and Information Science,
// School of Engineering and Applied Science, University of Pennsylvania
next prev parent reply other threads:[~2000-05-15 21:00 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-05-11 14:28 Stephanie Weirich
2000-05-12 20:38 ` Hongwei Xi
2000-05-15 8:49 ` Xavier Leroy
2000-05-15 17:47 ` Hongwei Xi
2000-05-15 21:33 ` Pierre Weis
2000-05-16 2:53 ` Hongwei Xi
2000-05-18 16:16 ` Pierre Weis
2000-05-19 6:54 ` Max Skaller
2000-05-22 15:28 ` Pierre Weis
2000-05-22 22:29 ` Max Skaller
2000-05-15 22:20 ` Dave Mason
2000-05-15 9:36 ` Eijiro Sumii [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-05-20 20:13 Simon Peyton-Jones
2000-05-22 16:10 ` Pierre Weis
2000-05-11 13:48 Dave Berry
2000-04-25 18:16 Caml wish list Pierre Weis
2000-05-10 4:50 ` reference initialization Hongwei Xi
2000-05-11 13:58 ` Pierre Weis
2000-05-11 18:59 ` Hongwei Xi
2000-05-12 17:07 ` Pierre Weis
2000-05-12 19:59 ` Hongwei Xi
2000-05-15 6:58 ` Max Skaller
2000-05-15 17:56 ` Hongwei Xi
2000-05-14 14:37 ` John Max Skaller
2000-05-13 7:07 ` Daniel de Rauglaudre
2000-05-13 7:09 ` Daniel de Rauglaudre
2000-05-11 16:02 ` John Prevost
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=20000515053606J.sumii@saul.cis.upenn.edu \
--to=sumii@saul.cis.upenn.edu \
--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).