Subject: Re: compiling/0

From: Jan Wielemaker <[email-masked]>
Date: Thu, 2 Dec 1999 17:11:56 +0100

> Your manual says:
> 
> compiling
>      Succeeds if the system is compiling source files with the -c option
> into an intermediate code file. Can be used to perform code optimisations in
>      expand_term/2 under this condition. 
> 
> 
> 
> 
> Now my example (t1.pl):
> 
> 
> --------------------------
> t :-
>   compiling,
>   write('*********in compiler'),nl.
> 
> t :-
>   not compiling,
>   write('*********not in compiler'),nl.
> 
> 
> :- initialization(t).
> -----------------------------
> 
> And my result:
> 
> $pl -c t1.pl
> *********not in compiler
> t1.pro compiled, 0.00 sec, 988 bytes.
> 
> ------------------------------
> 
> 
> Another magic problem?

No, an error in the manual.  Compiling is defined if we are compiling
directly to `Quick Load Format' as now used only by qcompile/1.  If you
want to know whether or not a file is being loaded, you should be able
to use prolog_load_context(file, File), which yields the file being
loaded or fails if no file is being loaded.

If you want a directive executed only at program startup, you can use

:- at_initialization(t).

Try ?- listing(initialization) and you know why :-)

	Regards --- Jan