[wg-camlp4] Time for a summary?
Hongbo Zhang
hongboz at seas.upenn.edu
Mon Feb 11 13:41:23 GMT 2013
On Mon, Feb 11, 2013 at 5:28 AM, Alain Frisch <alain.frisch at lexifi.com>wrote:
> On 02/07/2013 08:50 PM, Hongbo Zhang wrote:
>
>>
>> Again, I'm lost. Why is that difficult to support the suggested
> extensions to the grammar of OCaml in camlp4/camlp4/fan? The fact that
> attributes are ignored (or propagated) by the type-checker does not change
> anything: Pexp_annotation is just like a binary operator from a syntactic
> point of view. And what has Coq to do with it?
>
> The grammar parser (the same as stream parser) relies on quasi-quotation.
Though I do not know how camlp5 implemented it, but I think they have a
similar implementation. (coq depends on p5)
>
> First, I guess most people will seldom write ppx, and they have to
>> remember all those function names for once use a year. Quosi-quotation
>> is so intuitive that you don't need remember anything.
>>
>
> Yes, to write (robust) code generators or transformers, you need to know
> about the OCaml AST. I suspect most people who have written Camlp4
> extensions are somehow familiar with the OCaml parse tree. And we should
> make the Parsetree more accessible:
>
> - Clean up some of its rough edges (or introduce a variant of Parsetree
> which looks more like a parse tree than an AST; I'm not completely decided
> on that point yet).
>
> - Provide a tool / compiler command-line option to dump a fragment of
> parsed source code in "Parsetree" syntax (as discussed with X. Clerc on
> this list).
>
> This is a hack, it may help you to write, but does not help you to read
the code.
>
>
>
> Second, as I said, quosi-quotation works so nice with IDE or Emacs,
>> since you can expand code any time you want, just one key binding, the
>> expanded code just show up in my emacs buffer
>>
>
> Could you clarify how this would work? My understanding of quotations in
> Fan is still that they should be completely ignored by editors, because you
> can put arbitrary syntax in them, so it doesn't make sense to apply OCaml
> "rules" (coloring, indentation, folding, etc) to them.
Suppose you embed arbitrary functions to construct the ast,
"E.let_ (E.appfun_ ...)"
If you select the region, the IDE does not know how to expand this region
to view the expanded code.
For quosi-quotaiton, instead
"let a = fun b -> c"
The ide knows how to expanded this part of code to visualize its AST.
>
>
>
> Third, this way to construct code is very limited, think about how you
>> encode the ast, "{:expr| {:expr| a + b|} |}"
>>
>
> It's a good example of something I've never wanted to do and which is not
> required to implement any of the "extensions" I'd be interested to use.
>
> Sometimes the fact people never think about to do something is due to the
current tool they use does not provide such ability. Nested quotation is a
common idiom for meta programming
>
>
> Regards,
>
> Alain
>
--
-- Regards, Hongbo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ocaml.org/pipermail/wg-camlp4/attachments/20130211/8aa5404a/attachment.html>
More information about the wg-camlp4
mailing list