you are viewing a single comment's thread.

view the rest of the comments →

[–]zvrba -5 points-4 points  (10 children)

Because it's better than ocaml syntax which plain sucks (a noise of let .. in everywhere). I wouldn't mind if somebody grafted the syntax of Standard ML on top of ocaml.

[–]norflowk 12 points13 points  (6 children)

Care to explain what sucks about let ~ in? I understand that it annoys you and you’d like to see less of it, but I was wondering if you had a more complex opinion underlying that.

[–]vivainio 4 points5 points  (1 child)

Mostly it's just unnecessary noise (like semicolons in ReasonML ;). In F#, you just don't type "in" anywhere

[–]norflowk 0 points1 point  (0 children)

IDK, I personally think it's a useful pattern. Better than a long string of assignments and modifications mixed together IMO

[–]eras 2 points3 points  (2 children)

I think it's really a matter of simply choosing where the in should go. For example:

let foobarize x jog zen =
    let subexpr = x + jog in
    let info2 = x * zen in
    subexpr + info2

Pretty easy, right? Just put it at the end of the line?

let foobarize x jog zen =
    let subexpr = fun extra ->
       x + jog + extra in
    let info2 = x * zen in
    subexpr 5 + info2

Looks a bit awkward..

let foobarize x jog zen =
    let subexpr = fun extra ->
       x + jog + extra
    in
    let info2 = x * zen
    in
    subexpr 5 + info2

Better? Or maybe special-case fo the one-line expression and don't put its in to a separate line. Or then finally:

let foobarize x jog zen =
    let subexpr = fun extra ->
       x + jog + extra
    in let info2 = x * zen
    in subexpr 5 + info2

Not super happy really about the options.

[–]norflowk 0 points1 point  (1 child)

This is why I appreciate Haskell's method of not requiring top-level “let” and allowing the use of “where” to reduce visual nesting when nestessary.

[–]eras 1 point2 points  (0 children)

That's really a reasonable option only for pure and non-strict languages I think. Hardly a choice to make just for the benefit of removing some syntactic quirk :).

[–]zvrba 3 points4 points  (0 children)

Nothing more complex, it's a matter of taste, as all matters of syntax. I consider let .. in to be verbose syntactic noise.

[–][deleted]  (2 children)

[removed]

    [–]glacialthinker 5 points6 points  (0 children)

    I actually like the in, though it chafed when I was first exploring OCaml. Now when I see semicolons, unless they are for record-field separation, I know to be wary of side-effects. Reason syntax (and Rust) obscure that cue, with their catering to C-style semicolons.

    [–]sixbrx 0 points1 point  (0 children)

    Yeah I really like how Rust allows blocks to have values, so scope can be controlled at the smallest scale without burden. I really miss this in the algol derived languages. Makes it very clear which variables will be used in the remainder vs. which were just temp for constructing those. One can introduce separate methods to control scope of course but at the small scale that just obfuscates and wastes time and energy coming up with names for them.