You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 5198 Reporter: lealanko Status: closed (set by @xavierleroy on 2015-12-11T18:24:15Z) Resolution: won't fix Priority: normal Severity: feature Category: ~DO NOT USE (was: OCaml general)
Bug description
This is the classic ocaml syntax pet peeve. Might as well make a feature request out of it, so if it gets rejected, there's an "official record" of it and no one need bother with it ever again.
Other syntax issues aside, the most annoying ocamlism is the syntax for sequential lets, particularly the tailing "in". If one writes in an expression context:
let foo = bar baz quux in
let drokk = fnord fnarp zool in
...
then the tailing "in" is visually indistinguishable from the preceding arguments if they are short variable names, and one is heavily dependent on syntax highlighting to clarify the structure of the program. Alternatively, if one writes
let foo = bar baz quux
in let drokk = fnord fnarp zool
in ...
then the structure is clearer, but the indentation is inconsistent. Of course one could give extra indentation to the first line, but that would require special tool support and it would look kind of weird. The neatest solution currently is:
let foo = bar baz quux
in
let drokk = fnord fnarp zool
in
...
but that obviously wastes space quite a bit.
It is strange that this sequential let construct, though ubiquitous in all ocaml code, is so cumbersome, whereas "let ... and ..." has a very nice syntax, although it is only needed in special circumstances where one needs to shadow several variable names at once.
There is an obvious solution to this problem: just provide special support for sequential lets by allowing a let to directly follow a preceding let without an intervening "in":
let foo = bar baz quux
let drokk = fnord fnarp zool
in ...
This shouldn't cause any syntax ambiguities because the very same syntax for lets is already supported in module bodies!
I'm inclined to suspect that this option has already been intentionally rejected for some reason because it is so obvious, but one can always hope. All the other syntax issues in ocaml are minor in comparison to this one.
The text was updated successfully, but these errors were encountered:
This would be quite hard to parse with a yacc grammar because you need to look ahead all the way to the "in" keyword in order to differentiate between (as a module body)
let a = 1 let b = 1
and
let a = 1 let b = 1 in 1
Original bug ID: 5198
Reporter: lealanko
Status: closed (set by @xavierleroy on 2015-12-11T18:24:15Z)
Resolution: won't fix
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Bug description
This is the classic ocaml syntax pet peeve. Might as well make a feature request out of it, so if it gets rejected, there's an "official record" of it and no one need bother with it ever again.
Other syntax issues aside, the most annoying ocamlism is the syntax for sequential lets, particularly the tailing "in". If one writes in an expression context:
let foo = bar baz quux in
let drokk = fnord fnarp zool in
...
then the tailing "in" is visually indistinguishable from the preceding arguments if they are short variable names, and one is heavily dependent on syntax highlighting to clarify the structure of the program. Alternatively, if one writes
let foo = bar baz quux
in let drokk = fnord fnarp zool
in ...
then the structure is clearer, but the indentation is inconsistent. Of course one could give extra indentation to the first line, but that would require special tool support and it would look kind of weird. The neatest solution currently is:
let foo = bar baz quux
in
let drokk = fnord fnarp zool
in
...
but that obviously wastes space quite a bit.
It is strange that this sequential let construct, though ubiquitous in all ocaml code, is so cumbersome, whereas "let ... and ..." has a very nice syntax, although it is only needed in special circumstances where one needs to shadow several variable names at once.
There is an obvious solution to this problem: just provide special support for sequential lets by allowing a let to directly follow a preceding let without an intervening "in":
let foo = bar baz quux
let drokk = fnord fnarp zool
in ...
This shouldn't cause any syntax ambiguities because the very same syntax for lets is already supported in module bodies!
I'm inclined to suspect that this option has already been intentionally rejected for some reason because it is so obvious, but one can always hope. All the other syntax issues in ocaml are minor in comparison to this one.
The text was updated successfully, but these errors were encountered: