caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christian Lindig <lindig@cs.uni-sb.de>
To: skaller <skaller@ozemail.com.au>
Cc: Caml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] line number information in abstract syntax trees
Date: Fri, 19 Sep 2003 08:50:08 +0200	[thread overview]
Message-ID: <20030919065008.GA16990@st> (raw)
In-Reply-To: <1063911675.19351.7.camel@pelican>

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


      reply	other threads:[~2003-09-19  6:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-15  7:53 Rafael 'Dido' Sevilla
2003-09-15 11:14 ` Michal Moskal
2003-09-16 20:07 ` skaller
2003-09-17  8:44 ` Christian Lindig
2003-09-18 19:01   ` skaller
2003-09-19  6:50     ` Christian Lindig [this message]

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=20030919065008.GA16990@st \
    --to=lindig@cs.uni-sb.de \
    --cc=caml-list@inria.fr \
    --cc=skaller@ozemail.com.au \
    /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).