<div dir="ltr">I would be very happy to see some killer applications written using extension_point to be convinced that extension_point is awesome for metaprogramming.<div style><br></div><div style>Currently, I am building a c code generation framework and continuing jaked's work on ocamljs on top of Fan. I really learned a lot during the development and did fix some bad designs of Fan, such a way of learning may also benefit the design of extension_point.</div>
<div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 2, 2013 at 3:33 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">Hi Gabriel,<br>
<br>
Thanks for the feedback.<br>
<br>
I think it is to be understood that -ppx and extension_point do not target "syntax extension in the small", as you say.  I'd go as far as to say that they are not really about "syntax extension", since the whole idea is not to touch the concrete syntax.  Compared to Camlp4, Camlp5 or Fan, indeed, we loose the ability to provide nice little convenient syntactic shortcuts, and for this reason, there will still be some space for those tools, for people actually interested in changing the concrete syntax (and accepting the price to pay for it, in particular having to adapt their editor mode).  Luckily, I believe that most of the wide-spread current uses of Camlp4 don't fall in this category where the syntactic compactness is the ultimate goal:<br>

<br>
  - code generation driven by type declaration;<br>
<br>
  - code instrumentation (ą la Bisect);<br>
<br>
  - macro/conditional compilation;<br>
<br>
  - monadic syntax (--> e.g. suggested syntax for lwt: let%W p = ...)<br>
<br>
  - custom pattern matching (bitstring, ulex).<br>
<br>
<br>
As a side note, I've recently changed the syntactic category accepted as arguments of attributes/extensions from expressions to structures, which are strictly more general (an expression is also syntactically a valid structure item, and thus a structure, in itself).<br>

<br>
It was also discussed, some time ago, to merge the syntactic categories of expressions and patterns (patterns are already "almost" a sub-category of expressions).  This could have helped in your case (not for the "when" part, though).<div class="im">
<br>
<br>
On 05/01/2013 04:44 PM, Gabriel Scherer wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
For the purpose of experimentation, I still decided to do an<br>
implementation based on a horrible hack, namely using (the new syntax<br>
for) string literals that had been presented as a way to get "foreign<br>
language quotations" in this context, with the syntax [%matches {|<br>
<patt> when <expr> |}]. I believe this course of action should be<br>
discouraged; in particular, there is no proper error handling. It<br>
seems that deploying extensions based on this principle would<br>
constitute a regression from the current Camlp4 situation.<br>
</blockquote>
<br>
<br></div>
I know that you're allergic to this approach, but you could also have adopted the following syntax:<br>
<br>
{matches|<patt>|}<br>
{matches|<patt> when <expr>|}<br>
<br>
i.e. reusing syntax for an otherwise valid expression (a string literal).  Indeed, the "marker" for new string literals is kept in the Parsetree.  And those string literals have the nice property that a position within the string literal can be mapped to a location in the source code (just shift by N+2 characters, where N is the length of the string market, 7 in that case).  Indeed, no character within the string literal is interpreted in a special way (no escaping or special character) and whitespaces are not allowed around the marker.  This would support exact error reporting.<br>

<br>
Leo has proposed to provide a combined syntax for extension node + quotation. This would give a cleaner way, of course, compared to piggy-backing valid syntax.<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
<br>
Alain</font></span><div class="HOEnZb"><div class="h5"><br>
______________________________<u></u>_________________<br>
wg-camlp4 mailing list<br>
<a href="mailto:wg-camlp4@lists.ocaml.org" target="_blank">wg-camlp4@lists.ocaml.org</a><br>
<a href="http://lists.ocaml.org/listinfo/wg-camlp4" target="_blank">http://lists.ocaml.org/<u></u>listinfo/wg-camlp4</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>-- Regards, Hongbo
</div>