[wg-camlp4] Request for feedback

Alain Frisch alain.frisch at lexifi.com
Thu Mar 14 08:34:47 GMT 2013


On 03/13/2013 10:32 PM, Leo White wrote:
> Sorry, what i meant was that it should be ([@id arg] expr) instead of
> ((@arg) expr). In other words, it should be square brackets like the
> other attributes.

Oh yes, sorry, of course.

> I do think that
>
>    let % lwt x = ...
>
> is potentially confusing. Maybe it would be better as
>
>    let . lwt x = ...
>
> since people nearly always write dots without spaces, and a dot
> obviously can't be an operator.

If people see examples written "let%lwt", they will probably do the 
same, don't you think?   "%" does not seem very common in OCaml code; I 
don't think people already have "bad habits" about it.  And if people 
insist to write "let % lwt", it will be because they believe it somehow 
better.

I'm not very fond of "let.lwt".  The dot symbol has already so many 
different uses in OCaml...  At least "%" is quite rare and will thus be 
clearly noticed as an extension.

> Another posibility would be
>
>    let .% lwt x = ...

Do you believe it is worth making the syntax more heavy only to 
discourage (and not even prevent) people from potentially writing code 
with a style we don't like?

> It does seems like we're going from having a single extension syntax to
> having many extension syntaxes. I can see the benefit of "let % lwt"
> since that will probably be a common extension point (the same goes for
> "match % bit") but is there much to be gained from the other possible
> keyword extensions.

function%ext and try%ext are also probably useful.

And I can imagine examples where {%ext x1=e1; ...; xn=en} would be 
useful as well (see the "pre-polyrecord" example).

At this point, why not be uniform, and do the same for all kinds of 
expressions starting with a well-defined keyword or symbol, including 
the parenthesized expressions "begin%ext expr end" and "(%ext expr)". 
For other syntactic categories than expressions, this last form would be 
recognized (as the only syntax for extensions), instead of "[%ext 
expr]".  There is a single syntax.

> While "let % lwt" may be alright, I do think that
>
> ( % id expr )
>
> is a bad idea. It looks too much like a prefix operator. Also, having a
> two character delimiter that isn't a single token is different from
> every other two character delimiter in the langauge. It also means that
> you can't use precedence to resolve conflicts in the parser. Is there
> any real benefit in using (%id expr) instead of [%id expr]?

The benefit I can see is the uniformity with other forms of expressions:

    KW%id ...

where KW is the opening keyword/symbol (here "(") and ... the rest of 
the construction starting with KW.


Alain


More information about the wg-camlp4 mailing list