New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use a | at the beginning of an or-pattern #7296
Comments
Comment author: @alainfrisch Being able to use for the first clause of a match/function is nice, but the equivalent for or-pattern seems much less useful. I don't think this deserves reserving the banana tokens (|...|) that will certainly find some use in OCaml at some point. |
Comment author: @johnwhitington Then perhaps require a space before the |. This sort of disambiguation already occurs with polymorphic variant type declarations: # type 'a vlist = [`Nil | `Cons of 'a * 'a vlist];;
type 'a vlist = [ `Cons of 'a * 'a vlist | `Nil ]
# type 'a vlist = [|`Nil | `Cons of 'a * 'a vlist];;
Error: Syntax error
# type 'a vlist = [ | `Nil | `Cons of 'a * 'a vlist];;
type 'a vlist = [ `Cons of 'a * 'a vlist | `Nil ] |
Comment author: @xavierleroy Indeed, #7267 wants to use (| for another purpose... I'm not a big fan of the proposed extension. |
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
Original bug ID: 7296
Reporter: @johnwhitington
Status: acknowledged (set by @gasche on 2016-07-20T14:50:59Z)
Resolution: open
Priority: low
Severity: feature
Version: 4.03.0
Target version: later
Category: lexing and parsing
Related to: #7267
Monitored by: @gasche
Bug description
The OCaml style guide prefers
However, one cannot use the initial | in an or-pattern:
I've never needed this before, but I tried to use it in real code today, to line up columns:
The text was updated successfully, but these errors were encountered: