News for hackers. Stuff that matters.
Re:Introduction to Functional Programming in OCaml by diaz on Thursday August 23, 2018 @10:56AM (#17827759)
As a contrasting opinion I started reading the Ocaml book about something real world and I felt the syntax finally something fresh, beatiful and clean. But I also suffer from having to use scala everyday at work.
Re:Introduction to Functional Programming in OCaml by ufo on Thursday August 23, 2018 @11:06AM (#17827836)
As a big Ocaml fan, the syntax is one of my least favourite aspects of the language.

Two things that I find particularly annoying are constructors (which don't have the same syntax as funciton calls) and the multitude of shift-reduce ambiguities that don't do the thing that you want. For example, in the following code the W gets parsed as part of the inner match:

    match foo with
      | X -> match bar with
               | Y -> 1
               | Z -> 2
      | W -> 3
A lot of this could be remedied by having more expression terminators. ReasonML uses C-like curly braces but even a simple "end" token to close the match expressoin (similar to what Lua does) would already be enough.
Re:Introduction to Functional Programming in OCaml by anuragsoni on Thursday August 23, 2018 @11:27AM (#17828031)
This tripped me up when I was first exploring OCaml. FWIW i've taken to wrapping the nested matches with parenthesis or a begin/end

    match foo with
      | X -> (match bar with
               | Y -> 1
               | Z -> 2)
      | W -> 3

    match foo with
      | X -> begin match bar with
               | Y -> 1
               | Z -> 2
             end
      | W -> 3
Re:Introduction to Functional Programming in OCaml by nestorD on Thursday August 23, 2018 @11:46AM (#17828213)
The indentation sensitive syntax of F# was the solution to me, I would love to see it being integrated into OCaml.
Re:Introduction to Functional Programming in OCaml by diaz on Thursday August 23, 2018 @01:57PM (#17829300)
Ohh interesting. Didn't get that far yet. But good to know. Is there somekind of place listing these gotchas with the syntax? Seems something good to be aware.
Re:Introduction to Functional Programming in OCaml by scns on Thursday August 23, 2018 @03:26PM (#17829921)
Check out the point "comparison to ocaml" in the reasonml docs