Calling OCaml-wrapped ZeroMQ code from signal handler

There are two potential problems: Inside a signal handler, you can only call asynchronous signal safe functions. Most functions are not async signal safe. The reason for the restriction is that a function could be called in the middle of the same function’s execution. Thus, internal state could be corrupted. Very few functions are async … Read more

What is the state of OCaml’s parallelization abilities?

This 2009 issue of the Caml weekly news (“CWN”, a digest of interesting messages from the caml list) shows that: the official party line on threads and Ocaml hasn’t changed. A notable quote: (…) in general, the whole standard library is not thread-safe. Probably that should be stated in the documentation for the threads library, … Read more

Print a List in OCaml

You should become familiar with the List.iter and List.map functions. They are essential for programming in OCaml. If you also get comfortable with the Printf module, you can then write: open Printf let a = [1;2;3;4;5] let () = List.iter (printf “%d “) a I open Printf in most of my code because I use … Read more

What’s the difference (if any) between Standard ML’s module system and OCaml module system?

There are some differences feature-wise, as well as semantically. Features SML supports but not OCaml: transparent signature ascription module-level let symmetric sharing constraints syntactic sugar for functors over types and values Features OCaml 4 has but not SML: higher-order functors recursive modules local modules nested signatures modules as first-class values general module sharing (sig with … Read more

What’s the reason of ‘let rec’ for impure functional language OCaml?

When you define a semantics of function definition, as a language designer, you have choices: either to make the name of the function visible in the scope of its own body, or not. Both choices are perfectly legal, for example C-family languages being far from functional, still do have names of definitions visible in their … Read more