<br><br><div class="gmail_quote">On Mon, Feb 11, 2013 at 5:28 AM, Alain Frisch <span dir="ltr"><<a href="mailto:alain.frisch@lexifi.com" target="_blank">alain.frisch@lexifi.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 02/07/2013 08:50 PM, Hongbo Zhang wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br></div></blockquote>
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?<div class="im">
<br></div></blockquote><div>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)  </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
First, I guess most people will seldom write ppx, and they have to<br>
remember all those function names for once use a year. Quosi-quotation<br>
is so intuitive that you don't need remember anything.<br>
</blockquote>
<br></div>
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:<br>

<br>
 - 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).<br>
<br>
 - 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).<div class="im"><br></div></blockquote><div>This is a hack, it may help you to write, but does not help you to read the code.</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Second, as I said, quosi-quotation works so nice with IDE or Emacs,<br>
since you can expand code any time you want, just one key binding, the<br>
expanded code just show up in my emacs buffer<br>
</blockquote>
<br></div>
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.</blockquote>
<div>Suppose you embed arbitrary functions to construct the ast,</div><div><br></div><div>"E.let_ (E.appfun_ ...)"</div><div>If you select the region, the IDE does not know how to expand this region to view the expanded code.</div>
<div><br></div><div>For quosi-quotaiton, instead</div><div>"let a = fun b -> c"</div><div>The ide knows how to expanded this part of code to visualize its AST. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Third, this way to construct code is very limited, think about how you<br>
encode the ast, "{:expr| {:expr| a + b|} |}"<br>
</blockquote>
<br></div>
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.<br>
<br></blockquote><div>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</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
<br>
Regards,<br>
<br>
Alain<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>-- Regards, Hongbo