Remix.run Logo
IshKebab 8 months ago

I 100% agree. The lack of clear scoping and function call grouping syntax just turns it into a word soup. It becomes difficult to parse for humans and I spend a stupid amount of time just getting the semicolons, begin/ends, etc. right.

It's like... when you mismatch brackets or braces in a C-style language, except to resolve the problem you can't just find the bracket that's highlighted in red and count; you have to read an essay.

I don't know why there are so many people here defending it. It's pretty clearly very elegant, but extremely inconvenient.

edwintorok 8 months ago | parent | next [-]

That can be indeed very confusing when you initially learn the language. However there are 3 things that can help:

* An auto-formatter (ocamlformat integration in your editor, or ocaml-top) that shows how the actual nesting looks like

* You can add ;; at the end of a top-level function to get a syntax error at a better location

* Use the LSP integration of your editor which will show you where the error is as you type, so you catch the problem early

IshKebab 8 months ago | parent [-]

> Use the LSP integration of your editor which will show you where the error is as you type, so you catch the problem early

Yeah I do have this set up and it's a very good LSP, but unfortunately frequently if you get the nesting wrong the error is like "the entire rest of the file is wrong". It's often not very helpful.

That's not unique to OCaml. C style syntaxes can give "everything after this point is an error" if you get brackets wrong, but it's much easier to figure out what you did wrong.

dgan 8 months ago | parent | prev [-]

Use ocamlformat and set "profile = janestreet"