From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id DD4B1BC6B for ; Sat, 15 Dec 2007 17:54:33 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAO6VY0fAXQInh2dsb2JhbACQAQEBAQgKKYEUlgc X-IronPort-AV: E=Sophos;i="4.24,172,1196636400"; d="scan'208";a="6864488" Received: from concorde.inria.fr ([192.93.2.39]) by mail3-smtp-sop.national.inria.fr with ESMTP; 15 Dec 2007 17:54:33 +0100 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id lBFGsWs4006881 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sat, 15 Dec 2007 17:54:33 +0100 X-IronPort-AV: E=Sophos;i="4.24,172,1196636400"; d="scan'208";a="6864487" Received: from yquem.inria.fr ([128.93.8.37]) by mail3-relais-sop.national.inria.fr with ESMTP; 15 Dec 2007 17:54:32 +0100 Received: by yquem.inria.fr (Postfix, from userid 25991) id AAC10BC6B; Sat, 15 Dec 2007 17:54:32 +0100 (CET) Date: Sat, 15 Dec 2007 17:54:32 +0100 From: Daniel de Rauglaudre To: caml-list@inria.fr Subject: Re: [Caml-list] How to Create Sensible Debugging Information when Dynamically Typechecking Code Generated with camlp5 Quotations Message-ID: <20071215165432.GB31424@yquem.inria.fr> References: <606064.60999.qm@web60114.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <606064.60999.qm@web60114.mail.yahoo.com> User-Agent: Mutt/1.5.9i X-Miltered: at concorde with ID 476406C8.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; rauglaudre:01 rauglaudre:01 camlp:01 statically:01 runtime:01 runtime:01 syntax:01 camlp:01 ocaml:01 syntax:01 semantics:01 foo:01 foo:01 expander:01 expr:01 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/