Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Announcement: pa_bounds
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-03-13 (06:43)
From: Martin Jambon <martin_jambon@e...>
Subject: Announcement: pa_bounds
As suggested by Rich Jones, here is a better description of this new 
syntax extension:

                   pa_bounds syntax extension

Location-specific reports of out-of-bounds accesses in arrays, strings and 

What it provides:
The default behavior of out-of-bounds array, string or bigarray accesses
is to raise the Invalid_argument exception, with no information on where
the faulty access was attempted.
This Camlp4 module provides a special syntax which allows the illegal
accesses to be reported accurately, by indicating the location
in the source code. The same exception, Invalid_argument, is raised, but
its argument is a string which contains that information.

The syntax:
Replace the dot (.) by the number sign (#), e.g.:

     native             extension
     a.(i)              a#(i)
     a.(i) <- e         a#(i) <- e
     s.[i]              s#[i]
     s.[i] <- c         s#[i] <- c
     big.{i,j}          big#{i,j}
     big.{i,j} <- x     big#{i,j} <- x

It should also work with the revised syntax, where ":=" replaces "<-".


   The native behavior can be restored without changing the program by
   passing the -native option to the preprocessor. For unsafe access
   without bound checking, this option must be used in addition to the
   -unsafe option that can be passed to the compiler (ocamlopt or ocamlc).

Install Findlib and P4ck, and then install it from P4ck.
Alternatively, you can compile the extension as follows:
   camlp4o -o ocamlc -c \
          -pp 'camlp4o pa_extend.cmo q_MLast.cmo -loc _loc' \
          -I +camlp4

See for
information on how to compile programs that use Camlp4 extensions.

BSD-style, see


Martin Jambon, PhD

Edit, bioinformatics wiki