From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id IAA31441; Fri, 19 Sep 2003 08:50:13 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA07215 for ; Fri, 19 Sep 2003 08:50:12 +0200 (MET DST) Received: from indyio.rz.uni-saarland.de (indyio.rz.uni-saarland.de [134.96.7.3]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h8J6oB506129 for ; Fri, 19 Sep 2003 08:50:11 +0200 (MET DST) Received: from cs.uni-sb.de (cs.uni-sb.de [134.96.254.254]) by indyio.rz.uni-saarland.de (8.12.10/8.12.9) with ESMTP id h8J6oA0Y20923178; Fri, 19 Sep 2003 08:50:11 +0200 (CST) Received: from mail.cs.uni-sb.de (mail.cs.uni-sb.de [134.96.254.200]) by cs.uni-sb.de (8.12.10/2003091100) with ESMTP id h8J6oAM5004782; Fri, 19 Sep 2003 08:50:10 +0200 (CEST) Received: from mail.st.cs.uni-sb.de (goscinny.cs.uni-sb.de [134.96.235.32]) by mail.cs.uni-sb.de (8.12.10/2003073000) with ESMTP id h8J6o92h006666; Fri, 19 Sep 2003 08:50:09 +0200 (CEST) X-Authentication-Warning: email: Host goscinny.cs.uni-sb.de [134.96.235.32] claimed to be mail.st.cs.uni-sb.de Received: from jacobs.cs.uni-sb.de (jacobs.cs.uni-sb.de [134.96.235.135]) by mail.st.cs.uni-sb.de (Postfix) with ESMTP id 5EEAC34B24C; Fri, 19 Sep 2003 08:50:09 +0200 (CEST) Received: by jacobs.cs.uni-sb.de (Postfix, from userid 7528) id EED0A97BA2; Fri, 19 Sep 2003 08:50:08 +0200 (CEST) Date: Fri, 19 Sep 2003 08:50:08 +0200 From: Christian Lindig To: skaller Cc: Caml Mailing List Subject: Re: [Caml-list] line number information in abstract syntax trees Message-ID: <20030919065008.GA16990@st> Mail-Followup-To: Christian Lindig , skaller , Caml Mailing List References: <20030915075339.GA20719@imperium.ph> <20030917084448.GD8771@st> <1063911675.19351.7.camel@pelican> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1063911675.19351.7.camel@pelican> X-No-Archive: yes X-URL: http://www.st.cs.uni-sb.de/~lindig/ User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; lindig:01 lindig:01 uni-sb:01 caml-list:01 44,:01 rafael:01 'dido':01 expr:01 expr:01 debugging:01 statically:01 enforced:01 recognizes:01 uni-sb:01 compiler:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, Sep 19, 2003 at 05:01:16AM +1000, skaller wrote: > On Wed, 2003-09-17 at 18:44, Christian Lindig wrote: > > On Mon, Sep 15, 2003 at 03:53:39PM +0800, Rafael 'Dido' Sevilla wrote: > > > and expr = > > ExprAt of (expr * region) (* <--- *) > > | Int of (StdPrims.std_string * ty option) > > > This representation comes in handy when you create an AST not by > > parsing, but directly. In this case you don't have to invent line > > numbers because you simply never would generate ExprAt nodes. > > This is a false sense of security. Synthesised terms may also contain > errors (for example type errors). I should have made my example more precise. In the Quick C-- compiler we have a pretty printer for the AST. An AST is normally produced by the parser where we record line number information in *At nodes; in addition, we can translate back our intermediate representation to source code, via the AST and pretty printer. When we do so, we don't bother with line number information because it is for debugging only. I still consider this appropriate. > The advantage of mandatory source references (as opposed to the > above style) is that you're *forced* as a programmer to consider > the issue at all times. Line number information become a dynamic property, and of course, they are less secure than statically enforced line numbers. I guess everybody here recognizes this as an instance of the familiar static vs. dynamic discussion. -- Christian -- Christian Lindig http://www.st.cs.uni-sb.de/~lindig/ ------------------- 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