Conversation
|
I'm not a fan of using ordinary operators for extensions. You could use #508 instead, or at least explicitly reserve some operators for use with extensions (IIRC this is how |
It may be a good idea to reserve it for extensions; I added a check in I disagree about the precedence level, since the level of Added: For those who haven't followed the "safe-syntax" discussion, the main issue as as follows. Consider the code if ... then
...
else
stmt1 ();
stmt2 ()This works as suggested by the indentation, but if we insert a |
|
I don't disagree that it would be a better precedence level for |
|
I see your point about confusing Added: This linting behaviour may need to come first in the PPX pipeline, since it may not be possible to tell if a |
|
Two years later, this proposal still lacks support, the precedence issue pointed by @lpw25 is a killer, and the LWT PPX grew additional syntaxes for sequencing. I move to close this PR. |
This PR adds a new class of low precedence operators suitable as statement separators. E.g. a rewriter may set up the following aliases:
e1 -; e2ase1; e2e1 >|; e2ase1 >|= fun () -> e2e1 >>; e2ase1 >>= fun () -> e2which could be used in an Lwt context:
I might have gone slightly overboard with the
extended_semicolon.mltest, so that provides a more elaborate example.Syntax
The operators are composed of a semicolon prefixed by one or more operator characters, except for a few constraints due to conflicts with existing syntax. The period is excluded from the operator characters here, since both
..and.may occur before;;and at least the latter before;. The>;operator also had to be excluded, since>works as a delimiter in type expressions, and may thus precede both;and;;. I'm not sure if this covers everything, so we should give this point some though before merging (with a "-" bullet in the change log).The precedence level is just above
if, as opposed to;, which is just below. This level was chosen to prevent a prefixedletexpression from affecting the grouping of statements underthenorelse, as discussed to length in #715 and related threads. I believe the-;operator suggested above provides a more well-behaved alternative to;for those who are okay with the heavier notation.Related
>>in lwt.;%lwtand Remove >> syntax from the PPX ocsigen/lwt#495 proposes to remove>>.