In this post, I propose Static Exceptions as a new language feature allowing programmers to express interesting control flows in a compact way.
The goal is to display the following to stdout:
(0,0) (1,1) (2,2) ... (1000000,1000000)
How would you implement that in OCaml? For such a simple task, we probably expect the program to be IO bound, right? Ok, let's try with the idiomatic way, which is to use format strings as provided by the Printf module from OCaml standard library:
Most languages provide some way to manipulate tuples of values with a proper label for each field. They are called structures in C, records in OCaml; objects as found in most mainstream OO languages extend this same notion.
In a previous post, I've described a proposal on how to get rid of Camlp4 to write simple syntax extensions. This proposal slowly becomes a reality:
It is often useful to get access to types at runtime, in order to implement generic type-driven operations. A typical example is a generic value pretty-printer. Unfortunately, the OCaml compiler does not keep type information at runtime. At LexiFi, we have extended OCaml to support runtime types.
In this post, I'd like to propose a new approach to extending the syntax of OCaml that does not depend on Camlp4. This proposal is the result of discussions with Xavier Clerc, Fabrice Le Fessant, Maxence Guesdon, and has been presented to the latest meeting of the Caml Consortium. It was also quickly mentioned by Xavier Leroy during his talk at the latest OCaml Users Meeting.
A little teaser for OCaml gurus: what does the function below do?
In OCaml, generic functions like comparison and hashing are quite useful but not very flexible. In this post, I'll explain some tricks that might be useful when you want to tweak the behavior of these generic functions for your own data structures.