4 ms·
The 'in' is what makes it difficult to understand for someone not familiar with OCaml syntax and semantics. Reason makes it easier.
by ngrilly 10y ago
The 'in' is what makes it difficult to understand for someone not familiar with OCaml syntax and semantics. Reason makes it easier.
- tom_mellior 10y agoI've heard that said, but I don't see how it's a big deal. OK, the very first example introducing let bindings would have to come with a sentence like "the 'in' part of 'let ... in' means 'in' just like in English: 'let' the binding be valid 'in' what follows". You don't have to define a whole new syntax where a single sentence in a language tutorial might be enough. But I admit that I probably can't fully appreciate whether this is really difficult for someone used to JavaScript.
- ngrilly 10y agoOf course, once you know what 'in' means, it's easy to read, but you have to learn it, and get used to it. I've teached programming to students in finance, and this learnt me how much I underestimated the impact small things like that can have on the learning curve (and the motivation).
- jordwalke 10y agoExcept when you're in the top level - in which case you don't use `in`. Oh, and don't forget all the nuance of interleaving imperative commands. I'm an experienced OCaml dev and this trips me up (the "ml compared" section of the docs lists some common pitfalls that Reason resolves).
- tom_mellior 10y agoAh, but here you seem to be talking about when to write 'in'. Reading it is much simpler: Just ignore that it's there, and voilà, you're set. (I'm an experienced OCaml dev and := versus <- trips me up from time to time when choosing which one to write, but not when reading code.)
- ubertaco 10y agoYeah, I don't know what doesn't read easily about "let x = 3 in x - 1" -- it is straightforward: x is equal to 3 in the expression "x - 1".