Version française
Home     About     Download     Resources     Contact us    
Browse thread
small Camlp4 code : get a free name
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: [Caml-list] small Camlp4 code : get a free name
Excerpts from Edgar Friendly's message of Wed Jan 23 22:35:16 +0100 2008:
> Martin Jambon wrote:
>  > Nice, but in theory, it may create identifiers that are bound to an
> > incorrect value when the programmer forgot to define such a value.
> > 
> > For example, module A should provide A.x to module B (= another .ml file).
> > If the programmer forgets to define A.x, the compiler should report the
> > error at the time of compiling b.ml. But if some camlp4 extension
> > operating over a.ml introduces a variable A.x and by chance it has the
> > same type as the expected A.x, then the compiler will remain silent and
> > B will use the wrong value for A.x.
> > 
> > 
> > Martin
> > 
> It seems to me that the only way to satisfy this requirement involves a
> distinct namespace for these variables.  Maybe
> Camlp4.Unique_identifiers.<generated identifier>?

You    cannot    always   use   the   dot   notation.   For   instance   <<let
Camlp4.Unique_identifiers.x = e1 in e2 >> would be wrong.

> But this seems isomorphic to the simpler solution of claiming a portion
> of the identifier space: __camlp4_unique_identifier_<generated identifier>.

Yes that's the poor man fresh function.

Best regards,

-- 
Nicolas Pouillard aka Ertai