Previous week   Up   Next week

Here is the latest Caml Weekly News, for the week of 26 August to 02 
September, 2003.

1) tags
2) New GODI version, also for 3.07beta2
3) OCamlODBC 2.6
4) I need a C preprocessor
5) ocamldsort
6) primality test for Big_int
7) Let-in vs beta-redex

1) tags
** Following the announcement for taggage, Cuihtlauac Alvarado announced:

Cool, yet another tag generator for ocaml :-)

Did you experienced trouble with otags for vim? In case you do, just
send me a bug report. Quoting a famous post on this mailing list, it
would make me feel like if I was not :

BTW, otags 3.06.8 (hopefully the last for 3.06) is there :

Includes some fresh patches sent by Chris Hecker and Hendrik Tews,
thanks for contributions.

** Issac Trotts then announced:

It just occurred to me that it would be nice to have tag files
containing only module names for .mli files.  If the file you're editing
contains "" and you want to know what it does, you put your
cursor on top of "List", press ctrl-] , and then search for map.  This
will take you to the right place more quickly than digging through a
bunch of entries for "map" that are in other modules.  Here's an

** Issac Trotts announced:

Version 1.1 of the leanest OCaml tag file generator for Vim is now

Whereas taggage is an alternative to otags, taglet works well with otags
(and slightly less well with taggage).  The README file tells how this

** Issac Trotts announced yet another version:

Here's another revision.  Enjoy!

Changes for version 1.2:

o Handling of .ml files having no .mli counterparts
o Handling of files containing no lines without slashes

From the README:

Why write another tagger?

 Taglet makes a tag file that just lists all the .mli files, which
 reduces the number of redundant tags and helps you get the
 documentation you want more quickly without having to dig through a
 bunch of identical tags.

 With otags, if I want to look up, I put my cursor over
 "map", press ctrl-], and look through a bunch of other map functions
 until I find the one I want.  With Taglet, I put my cursor over
 "List", press ctrl-], and am immediately in list.mli.  Then I search
 for "map" in list.mli.  Often, if the .mli file is short, I can find
 what I need without having to page down.

Why not just add Taglet's functionality to an existing tagger?

 Taglet is tiny and is useful alone, so it's nice to have it as a
 separate program.  I would like add its functionality to otags, but I
 haven't yet figured out how to do it.  Even if I do, Taglet will still
 be useful and easy to understand on its own.

** Issac Trotts had a final announcement:

Version 1.3 of the tiny tag file generator is now available with

o Emacs support (via -emacs option)
o Recursive directory processing
o Minor bug fixes


Its mission in life remains the same:

 Taglet makes a tag file that just lists all the .mli files (and .ml files
 having no .mli counterparts), which reduces the number of redundant tags
 and helps you get the information you want quickly without having to dig
 through lots of identical tags.

2) New GODI version, also for 3.07beta2
** Gerd Stolpmann announced:

GODI, the O'Caml source distribution in progress, is available
in a new version:


Further links:


Besides that this version installs 3.07beta2 by default, there are a
number of major changes:

- The bootstrap process has now a second stage. After the first stage,
  the fundamental packaging tools are installed (all written in C).
  The second stage automatically installs a minimum O'Caml environment

- After the second stage has finished, there is a new management
  tool on the system: godi_console (see below).

- I have worked through all of the *.mk files, and deleted everything
  that is not needed, either because it is not applicable to an
  O'Caml installation, or because godi_console does it already much
  better. I hope this improves the maintainability.

- The version number ordering has been improved, now 3.07beta2 < 3.07.

The installable packages themselves have not changed very much, although
many bugs could be fixed (thanks to everybody who sent me feedback).

godi_console is the user interface of GODI. It is possible to select
packages from a list, or to deselect packages. godi_console resolves
dependencies, and gives interactive feedback. Last but not least it is
also a monitor for the build process.

For a number of reasons, godi_console has a curses-based user interface,
but the package handling functions are collected in a library, so
another type of interface could be created with not too much effort.

godi_console currently cannot handle binary packages, and some functions
are a bit slow, but after intensive testing I am convinced that it has
good quality.

BTW, pxp does not work currently. This seems to be an incompatibility
between wlex and the lastest changes in the O'Caml lexer.

3) OCamlODBC 2.6
** Maxence Guesdon announced:

I'm pleased to announce the release 2.6 of OCamlODBC, an OCaml-C interface to
acces to databases through ODBC drivers.
The only change in this release is the support for the DataDirect "Connect For
ODBC" driver, allowing to access Oracle Databases.

You can get OCamlODBC here:

The driver I used can be found here:

I managed to connect to an Oracle 9i server.

4) I need a C preprocessor
** Richard Jones asked and Issac Trotts answered:

>Here is some code I've just written. CjsConfig.debug_menu is a
>compile-time constant.
> let debug_menu =
>   if CjsConfig.debug_menu then
>     Some (factory#add_submenu "Debug")
>   else
>     None in
> (* ... *)
> let single_step_ev_item, single_step_res_item, step_to_item,
>     dump_hiertext_item =
>   match debug_menu with
>     None -> None, None, None, None
>   | Some debug_menu ->
>       let factory = new GMenu.factory debug_menu ~accel_group in
>       let single_step_ev_item =
>         factory#add_item "Single Step (1 Event)"
>           ~key:GdkKeysyms._T in
>       let single_step_res_item =
>         factory#add_item "Single Step (1 Result Period)"
>           ~key:GdkKeysyms._Z in
>       let step_to_item = factory#add_item "Step To ..." in
>       factory#add_separator ();
>       let dump_hiertext_item =
>         factory#add_item "Dump HierText To Console"
>           ~key:GdkKeysyms._H in
>       (Some single_step_ev_item, Some single_step_res_item,
>        Some step_to_item, Some dump_hiertext_item)
> in
>Now in C I'd use the preprocessor:
>#ifdef DEBUG_MENU
> factory#add_submenu "Debug"
>#ifdef DEBUG_MENU
> let factory = new GMenu.factory debug_menu ~accel_group in
> let single_step_ev_item = factory#add_item "Single Step (1 Event)"
> (* etc. *)
>which results in briefer, faster and simpler to understand code.
>My question is what is the proper style for this sort of thing in
Here's one way, using the C preprocessor:

  ocamlc pp cpp -o gargle *)

#define GARGLE

#ifdef GARGLE
let () = prerr_endline "gargle is defined!"
let () = prerr_endline "gargle is not defined!"

Here's another way, using the camlp4 ifdef macro:

  ocamlc -pp "camlp4o pa_o.cmo pa_ifdef.cmo pr_o.cmo" -o gargle2 *)

define GARGLE

let () =
 ifdef GARGLE
   then prerr_endline "gargle is defined."
   else prerr_endline "gargle is not defined."

5) ocamldsort
** Dimitri Ara announced:

The latest version of ocamldsort (0.14) which was available on
my site when Jean-Christophe wrote this mail was buggy (actually the
makefile was buggy). If you've tried ocamldsort these days, please download
the new version (0.14.1) :

6) primality test for Big_int
** Francesco Abbate asked and Xavier Leroy answered:

> I was implementing a modular GCD algorithm for polynomial with
> big_int coefficients when I've discovered that there isn't any
> primality test in the Nums library.
> Someone can help me about this question ?

The Cryptokit library (
contains an implementation of probabilistic primality testing,
as part of RSA key generation.

The function is called "is_pseudoprime" and it's not exported, but it
shouldn't be hard to extract it from the sources.  It operates on type
"nat", so you'll have to stick a "Big_int.nat_of_big_int" conversion
on input.

The algorithm used is that of PGP 2.6: Fermat tests against 8 small
primes.  While not as sophisticated as Miller-Rabin, this test seems
good enough for PGP, so it's good enough for me :-)

> If possible I would avoid to implement a primality test by myself because
> - I have to study the Rabin-Miller test
> - I have to implement it in C to obtain a good speed (maybe ?)

No need for C: Caml code working at the "nat" level (hand-allocated
big natural integers) is plenty fast enough.

** Yamagata Yoriyuki also answered:

I think Numerix contains the Rabin-Miller test as an example.

cryptokit also includes an implementation of Rabin-Miller, but IIRC, it
does not work with arbitrary integers.

7) Let-in vs beta-redex
** Lukasz Stafiniak asked and John Gerard Malecki answered:

> Is let-in more efficient than beta-redex or are they computationally
> equivalent? Is let-in a syntax-sugar of beta-redex?

They may be conceptually different but they compile to pretty much teh
same thing.  A nice trick to learn about the code that ocamlc
generates is to use 'ocaml -dinstr'.  For example,

:; ocaml -dinstr
        Objective Caml version 3.07+beta 2

# let x = sin 2. in x *. x *. x;;
        const 2.
        ccall sin_float, 1
        acc 0
        acc 1
        acc 2
        ccall mul_float, 2
        ccall mul_float, 2
        return 2

- : float = 0.751826944668992803
# (fun x -> x *. x *. x) (sin 2.);;
        const 2.
        ccall sin_float, 1
        closure L1, 0
        appterm 1, 2
L1:     acc 0
        acc 1
        acc 2
        ccall mul_float, 2
        ccall mul_float, 2
        return 1

- : float = 0.751826944668992803

** Michal Moskal added:

let in is *not* equivalent to beta-redex because of typing. Type
variables are not generalized in beta-redex, for example consider:

let id x = x in
(id 1, id true) 


(fun id -> (id 1, id true)) (fun x -> x)

Using folding to read the cwn in vim 6+
Here is a quick trick to help you read this CWN if you are viewing it using
vim (version 6 or greater).

:set foldmethod=expr
:set foldexpr=getline(v:lnum)=~'^=\\{78}$'?'<1':1

If you know of a better way, please let me know.

Old cwn

If you happen to miss a CWN, you can send me a message
( and I'll mail it to you, or go take a look at
the archive ( or the RSS feed of the 
archives ( If you also wish to 
receive it every week by mail, just tell me so.


Alan Schmitt