From: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] How to Create Sensible Debugging Information when Dynamically Typechecking Code Generated with camlp5 Quotations
Date: Sat, 15 Dec 2007 17:54:32 +0100 [thread overview]
Message-ID: <20071215165432.GB31424@yquem.inria.fr> (raw)
In-Reply-To: <606064.60999.qm@web60114.mail.yahoo.com>
Hi,
On Fri, Dec 14, 2007 at 01:22:23PM -0800, echinuz echinuz wrote:
> The language, by itself, can be statically type checked, but since I
> allow antiquotations I must type check at runtime.
I don't understand that. Antiquotations do not imply runtime type
checking: they are just syntax.
> let x=... in
> let prog= <:prog<
> embedded commands...
> more embedded commands...
> >> in
> execute prog;;
>
> The problem with location information generated in camlp5 is that it
> gives the location relative to the quote.
If the above program is OCaml+Camlp5 (I mean, not your language with
your syntax and semantics), I don't understand what you say : the
location information is absolutely not relative to the quotation !
But, perhaps, you mean : in error messages, the entire quotation is
underlined even if the message concerns a sub-part of the quotation ?
By defaut, typing errors show the entire quotation, because the
system cannot know where is the precise location of the error,
a quotation being any text. There is no knowledge of the
correspondence between the quotation text and the syntax tree,
and even no guarantee that such a correspondence exists !
For example if the code is :
<:prog< this is a variable foo >>
and the typing error message is :
Unbound variable : foo
there is no reason why the variable "foo" would match the text "foo" of
the quotation text. It could be a quotation expander returning
<:expr< foo >> whatever the quotation text. Therefore the OCaml typing
has no reason to underline the text "foo" of the quotation.
This is why the default behaviour of the Camlp5 quotation system
set the entire quotation in the whole syntax tree of the quotation.
If you want to specify a specific location to a part of your quotation,
you have to create specific nodes <:expr< $anti:x$ >> or <:patt< $anti:x$ >>
around these nodes. See the chapter about quotations and the one about
locations in Camlp5 documentation.
If you use Camlp5 extensible grammars to parse your quotation, or parts
of your quotation, you may have your quotation or these parts of your
quotation correctly located, relative to the quotation, and a good usage
of the antiquotation nodes above should give you correct typing error
messages, relative to the entire program.
Location is indeed a difficult part in programming quotations. Bad
programmed, errors can be shown in unexpected parts of the program.
You have to read the documentation and understand exactly what things
mean.
Hope this helps.
--
Daniel de Rauglaudre
http://pauillac.inria.fr/~ddr/
prev parent reply other threads:[~2007-12-15 16:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-14 21:22 echinuz echinuz
2007-12-15 15:47 ` [Caml-list] " Nicolas Pouillard
2007-12-15 19:32 ` echinuz echinuz
2007-12-16 16:50 ` Daniel de Rauglaudre
2007-12-17 10:54 ` Nicolas Pouillard
2007-12-17 3:29 ` echinuz echinuz
2007-12-17 5:28 ` Daniel de Rauglaudre
2007-12-17 9:11 ` echinuz echinuz
2007-12-17 12:41 ` Daniel de Rauglaudre
2007-12-18 23:05 ` echinuz echinuz
2007-12-19 9:50 ` Daniel de Rauglaudre
2007-12-15 16:54 ` Daniel de Rauglaudre [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=20071215165432.GB31424@yquem.inria.fr \
--to=daniel.de_rauglaudre@inria.fr \
--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