[wg-camlp4] My uses of syntax extension
Fabrice Le Fessant
Fabrice.Le_fessant at inria.fr
Tue Jan 29 12:33:39 GMT 2013
On 01/29/2013 11:47 AM, Leo White wrote:
>>> I second Leo's idea to leave it to the preprocessor.
>>
>> I would strongly argue for a convention that has to be obeyed by all
>> preprocessors. If you leave it to the preprocessor, you will have to
>> call the preprocessor during the parsing, not during the typing, i.e.
>> you won't have access to the typing environment while expanding
>> macros. Consequently, your objectives were to be strictly more
>> powerful, but your system would actually be strictly less powerful.
>
> There is no reson that you cannot expand the preprocessor during typing.
> As I said in a previous post, all we need to provide is a function that
> will parse an expression upto the next unnested occurence of "$" or
> whatever the preprocessor is using to mark the end of its
> antiquotations. Preprocessors can then simply use this facility to
> handle their antiquotations themselves.
Ok, there are two debates here : one is about the implementation, the
other one is about the accessibility.
From the implementation point-of-view, you have to know all the parsers
at parsing time, because you need the function to recognize their
antiquotations. In my implementation of ocaml-templates, there was a
parser to load new parsers (<:dynlink<pa_to_string>>). These new parsers
would be loaded while parsing the string inside the quotation, i.e.
during typing, not during parsing. In your case, you would not be able
to do that, unless you provide natively this mechanism to load parsers
dring parsing.
From the accessibility point-of-view, having a convention for
quotations/anti-quotations is both simpler for users (they can
understand more of what is happening even if they don't know the syntax
extensions, because anti-quotations are always written in the same way),
and for developers (they don't need to provide a function to recognize
their own anti-quotations, and actually, they don't even need to think
about which delimiters to use for their syntax).
During such debates, I always think about Ruby's "convention over
configuration", and why some languages are widely adopted while they are
actually less powerful than OCaml (and Camlp4 is very powerful...).
--Fabrice
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fabrice_le_fessant.vcf
Type: text/x-vcard
Size: 380 bytes
Desc: not available
URL: <http://lists.ocaml.org/pipermail/wg-camlp4/attachments/20130129/8cd94159/attachment.vcf>
More information about the wg-camlp4
mailing list