[wg-camlp4] My uses of syntax extension
Hongbo Zhang
hongboz at seas.upenn.edu
Mon Jan 28 19:02:55 GMT 2013
3 parsers actually.
The original parser, the parser to patt, the parser to expr.
Besides, every user has to maintain 3 parsers if they want to use the
quotation, not only the compiler maintainer.
I would be happy to see a prototype work before other changes
On Mon, Jan 28, 2013 at 1:25 PM, Leo White <lpw25 at cam.ac.uk> wrote:
>
> I suggest that you might think twice before you think it's a viable option
>> ---------------------------
>> 2. *Copy and paste, creating two new versions of the parser. *One
>>
>> version will directly return Haskell abstract syntax for a Haskell
>> pattern, and the other will return Haskell abstract syntax for an
>> expression.
>> *This is potentially a maintenance nightmare.*
>>
>
> This part is referring to needing two parsing functions: one for the when
> the quotation is used as a pattern and one for when it is used as an
> expression. I don't think that needing two parsing functions is really a
> "maintenance nightmare". Also, with GADTs they don't need to be two
> separate functions anyway.
>
>
> Furthermore, we lose a lot of the benefits of the type checker:
>> a value of type TH.ExpQ is Haskell abstract syntax for an
>> expression, but knowing this tells us nothing about the type of
>> the Haskell expression represented by the abstract syntax. This
>> expression could be an Integer, a String or have any other
>> type—we know only that it is syntactically correct, not that it is
>> type correct.
>>
>
> This is a fair criticism: parsing to a value and then converting that into
> an AST fragment may catch some potential errors in a parser. However, this
> safety could also be obtained by creating the value and the AST in
> parallel, and simply discarding the data structure when parsing is
> finished. This may not be as "neat" as deriving the AST from the value, but
> it is also requires no special support.
>
>
>
>
--
-- Regards, Hongbo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ocaml.org/pipermail/wg-camlp4/attachments/20130128/198dd668/attachment.html>
More information about the wg-camlp4
mailing list