5 ms·
I think you must be confused. OCaml is not all that punctuation heavy and doesn't have overloaded operators to make it punctuation heavy.
by chc 15y ago
I think you must be confused. OCaml is not all that punctuation heavy and doesn't have overloaded operators to make it punctuation heavy.
- jacques_chester 15y agoI must be, but here's how I remember it (bearing in mind that memory is faulty). A few years ago I took a unit in my comp sci degree, "Programming Paradigms". The language used for teaching was F#, which is heavily inspired by OCaml. At one point we were given readings on OCaml programs and a particular operator popped up -- something like "is subtype of", I fail to recall exactly -- and it looked like :>? or :?> or similar. I bitched loudly in the unit forum about this operator, whereupon the professor politely informed me that he, in fact, had invented that little bit of syntax when he was a PhD student at INRIA. He didn't flunk me! Dr Rowan Davies, still the most scary-smart computer scientist I've met.
- silentbicycle 15y agoI haven't ever seen that in OCaml. Probably an F# extension. If you're going to complain about OCaml's syntax, I would start with having to use different arithmetic ops for int vs. floating point (+ vs. +.) and different indexing operators for strings and arrays ( s.(0) vs. s.[0] ). You get used to it pretty quickly, and OCaml more than makes up for it in other ways, but it is a bit annoying.
- jacques_chester 15y agoHe mentioned that he did a bunch of work object-system work on Caml that was published, but the INRIA guys didn't put it into the main version when they developed OCaml. It's possible it got transmitted into F# that way. Next time I see him I'll ask about it.
- swah 15y ago1.0 + 2.0 <- Not valid OCaml! :) But I love OCaml, I don't why it isn't more hacked/forked.
- tomp 15y ago> But I love OCaml, I don't why it isn't more hacked/forked. Because it has a fucked-up licence - you're not allowed to "fork" it in the usual sense of the word, you can only distribute the original source, and your modifications in a patch. The "free-for-all" licence is only available to commercial users.
- chc 15y agoOn rereading, I realized this might give a false impression. OCaml does allow the user to define an operator, but a confluence of the type system (which doesn't allow overloading and makes abstracting types sufficiently difficult that it doesn't justify the minor syntactic nicety of a custom operators) and precedence rules means that most OCaml code you'll see does not use a lot of weird operators like you'll find in advanced Haskell code. I'm not an OCaml guru, but that's what I've seen.
- ppog 15y agoNot OCaml per se, but at least one F# library makes liberal and very effective use of custom operators: FParsec, Stephan Tolksdorf's parser combinator library (http://www.quanttec.com/fparsec/reference/primitives.html http://www.quanttec.com/fparsec/reference/primitives.html). Of course, FParsec is adapted from the Haskell Parsec library, so maybe that just makes your point for you!