3 ms·
I've never heard of OCaml tuples being more common in arguments. If anything, my impression is they're discouraged (in OCaml, not SML) as a replacement for curr
by atombender 7y ago
I've never heard of OCaml tuples being more common in arguments. If anything, my impression is they're discouraged (in OCaml, not SML) as a replacement for curried arguments. E.g. see [1].
> is nonsense in a functional language
SML/OCaml and Haskell all use ->, so I'm not sure what you mean by this?
[1] https://stackoverflow.com/questions/10666913/why-prefer-currying-to-tuple-arguments-in-ocaml https://stackoverflow.com/questions/10666913/why-prefer-curr...
- markslicker 7y agoIt is quite common in SML/ML code I've encountered, probably not as common in modern OCaml. BTW, in OCaml let add ((a:int), (b:int)) : int = a + b Works just fine, whereas: let add ((a:int), (b:int)) -> int = a + b is nonsense, because '->' is a type constructer in OCaml (a function from types to types) not part of an ad-hoc syntax for function declarations (like Rust).
- atombender 7y agoRight, I'm not sure with OCaml is inconsistent there. -> is also used in pattern matching and in the syntax "fun x -> x + 1", perhaps it's some historical thing to avoid ambiguity?
- markslicker 7y agoThe above usage of -> is a syntax error in OCaml, -> can be used in the left hand side of a let expression, but only as part of a type expression. As you say the other usage is used to construct terms (clauses) that are used in pattern matching, of course Haskell does something similar. The Rust syntax seems to emulate functional programming, but inconsistently since -> is not used purely as a type constructor or term constructor something like a mix of both in the defintion of functions, also it doesn't seem to support currying.