novice's notes on learning OCaml

Richard Underwood/Uhtenwoldt ru at river.org
Fri Feb 23 20:41:11 EST 2007


Kragen Javier Sitaker writes:
>Here's another, smaller-scale example.  My unit tests largely consist
>of code like this:
>
>    assert ([45; 50] = eval (Atom [45; 50]));
>
>Maybe at some point I would like to use floating-point for all my
>interpreter's values instead of integers.  I could imagine a language
>where I could retain compatibility with these tests by making Atom
>into a function that does the necessary conversion for the old tests;
>but that language is not OCaml, because in OCaml, your functions
>cannot begin with capital letters.

So, write your unit test as

    assert ([45; 50] = eval (atom [45; 50]));
    atom x = Atom x

Or am I missing something basic?

>   A simpler syntax with fewer levels of precedence.  Maybe writing
>   OCaml in S-expressions would be going too far, or maybe not.
>   Clearly this would make it effectively a different language.

Do you know enough about Haskell to have a definite opinion about its
syntax?

(I think it is basically good though I would reduce the number of
levels of operator precedence a lot.)


More information about the Kragen-discuss mailing list