Previous week   Up   Next week
Hello,

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 :
  student-turned-professional-maker-of-animated-powerpoint-slideshows

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

  http://perso.rd.francetelecom.fr/alvarado/soft/otags-3.06.8.tar.gz

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 "List.map" 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
implementation:

   http://redwood.ucdavis.edu/~issac/taglet-1.0.tar.gz

** Issac Trotts announced:

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


   http://redwood.ucdavis.edu/~issac/taglet-1.1.tar.gz


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

** 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 List.map, 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


at

 http://redwood.ucdavis.edu/~issac/taglet-1.3.tar.gz


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:

http://ocaml-programming.de/packages/godi-bootstrap-20030826.tar.gz

PLEASE READ THE FILE "README"!!!

Further links:

- http://ocaml-programming.de/programming/godi.html
- https://gps.dynxs.de/

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:
http://www.maxence-g.net/Tools/ocamlodbc/ocamlodbc.html

The driver I used can be found here:
http://www.datadirect-technologies.com/products/odbc/docs/oracle-driver-faq.asp

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"
>#endif
>
>#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. *)
>#endif
>
>which results in briefer, faster and simpler to understand code.
>
>My question is what is the proper style for this sort of thing in
>OCaml?
>
>Rich.
>
Here's one way, using the C preprocessor:

(* gargle.ml
  ocamlc pp cpp -o gargle gargle.ml *)

#define GARGLE

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



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

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

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) :

ftp://quatramaran.ens.fr/pub/ara/ocamldsort/ocamldsort-0.14.1.tar.gz

==============================================================================
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 (http://pauillac.inria.fr/~xleroy/software.html)
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.

http://pauillac.inria.fr/~quercia/

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

http://pauillac.inria.fr/~xleroy/software.html

==============================================================================
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
        push
        acc 0
        push
        acc 1
        push
        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
        push
        closure L1, 0
        appterm 1, 2
L1:     acc 0
        push
        acc 1
        push
        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) 

vs.

(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
zM

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
(alan.schmitt@inria.fr) and I'll mail it to you, or go take a look at
the archive (http://pauillac.inria.fr/~aschmitt/cwn/) or the RSS feed of the 
archives (http://pauillac.inria.fr/~aschmitt/cwn/cwn.rss). If you also wish to 
receive it every week by mail, just tell me so.

==============================================================================

Alan Schmitt