From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA11659 for caml-redist@pauillac.inria.fr; Mon, 15 May 2000 23:00:14 +0200 (MET DST) Resent-Message-Id: <200005152100.XAA11659@pauillac.inria.fr> Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA16708 for ; Mon, 15 May 2000 11:37:10 +0200 (MET DST) Received: from dynabook.is.s.u-tokyo.ac.jp (esumii-dsl-gw.dca.net [216.158.25.176]) by concorde.inria.fr (8.10.0/8.10.0) with ESMTP id e4F9b3T01894 for ; Mon, 15 May 2000 11:37:06 +0200 (MET DST) Received: from localhost ([127.0.0.1]) by dynabook.is.s.u-tokyo.ac.jp with esmtp (Exim 3.12 #1 (Debian)) id 12rHIG-00038M-00; Mon, 15 May 2000 05:36:08 -0400 To: caml-list@inria.fr cc: sumii@saul.cis.upenn.edu Subject: RE: reference initialization In-Reply-To: References: X-Mailer: Mew version 1.94.1 on Emacs 19.34 / Mule 2.3 (SUETSUMUHANA) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20000515053606J.sumii@saul.cis.upenn.edu> Date: Mon, 15 May 2000 05:36:06 -0400 From: Eijiro Sumii X-Dispatcher: imput version 991025(IM133) Resent-From: weis@pauillac.inria.fr Resent-Date: Mon, 15 May 2000 23:00:14 +0200 Resent-To: caml-redist@pauillac.inria.fr > 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 // // currently visiting: Department of Computer and Information Science, // School of Engineering and Applied Science, University of Pennsylvania