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
[ANN] pa_where 0.4 : backward declarations
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: blue storm <bluestorm.dylc@g...>
Subject: [ANN] pa_where 0.4 : backward declarations
    <mfp> breaking caml-list's silence for anything else than
         some deep typing issue feels wrong :-P

Let's make him feel wrong.

mfp and I are pleased to announce the first public release of
pa_where, a camlp4 extension enabling backward declarations. The
"where" keyword, available in the revised syntax, and one of the
truly missed Caml-light friends, is back.

The syntax, however, is slightly different from the usual one :
"where" should be followed by another declarative keyword, such
as "let" : a where let a = b

It is possible to use the "where let" form inside expressions,
and the "where val" form at toplevel (structure items). Having
a different syntaxic form for toplevel and local declarations is
not the classical syntax standard, but was needed for
disambiguation issues.

It is however possible to use the good old "where a = b" syntax :
in absence of any declarative keyword, the "let" keyword is used
as default.

The revised syntax "where" is restricted because of the "dangling
and" issue. pa_where has no such restriction (what's one more
ambiguity in the classical syntax anyway ?). Here are the two
ambiguous cases :
   a where b where c => (a where b) where c
   let a = b where c and d => let a = (b where c and d)

It would be possible to extend the backward declarations to other
constructions such as "where module" or "where type". If you see
any use for it, do not hesitate to ask for the feature or send
a patch.

The final syntax, wich I think is a good compromise, is the
result of a debate on the #ocaml IRC channel (Freenode). If you
are about to write a syntax extension yourself, you should really
consider discussing your syntax considerations there (or maybe on
the mailing-list ?) : it is amazing how helpful such a debate can
be on a so subjective question.

Thanks in advance for any testing, comment, criticism, request or


Available archives (test and META files included) :

Highlighted HTML source for online reading :