Why O'Caml is not my favorite programming language (2007)
schani.wordpress.com
schani.wordpress.com
> let add3 x = x + 3 val add3 : int -> int
Plain numeric literals are int (32-bit integer). To make it generic:
> let inline add3 x = - let one = LanguagePrimitives.GenericOne in x + one + one + one;; val inline add3 : ^a -> ^e when ( ^a or ^b) : (static member ( + ) : ^a * ^b -> ^c) and ^b : (static member get_One : -> ^b) and ( ^c or ^b) : (static member ( + ) : ^c * ^b -> ^d) and ( ^d or ^b) : (static member ( + ) : ^d * ^b -> ^e)
Perhaps not pretty, but inlining provides a quick way around some limitations on generics.
While strings are not arrays, they are sequences (IEnumerable in .NET). Sequences can be infinite, so there's no Seq.reverse. But:
> "hello" |> Seq.toArray |> Array.rev ;; val it : char [] = [|'o'; 'l'; 'l'; 'e'; 'h'|]
Update: Ignore the above, pa_do is from 2008. Nevertheless focusing on a single feature of the language is a good reason to reject the entire thing? Even when it's like that for solid performance reasons -- ie. you want to know what integer type you are using because it greatly affects how fast your program will run.
Compare the syntax of OCaml (and ML in general) for:
(1) defining functions
(2) defining ordinary variables
(3) static variables
(4) variables scoped to two functions
with the same for your favourite imperative/OO language.
Here's the OCaml syntax:
(1)
let f x = ...
(2) let v = ...
(3) let f =
let v = ... in
let f () = ... in
f
(4) let f, g =
let v = ... in
let f () = ... in
let g () = ... in
f, gIts not, though.
> If you want an easy-to-use dynamic programming language, there are plenty better choices than Lisp
Huh, is there some new dynamic language that has completely slipped under my radar?