Subject: Re: [SWIPL] I can not use system predicates after failure

From: Jan Wielemaker <[email-masked]>
Date: Thu, 8 Feb 2001 11:37:25 +0100

> Thanks for your reply.
> I read through my code and find the following interesting stuffs.
> 
> in file 'file001.pl':
> ------------------------------------------------
> set_swipl:-
> 	style_check(-discontiguous),
> 	style_check(-singleton),
> 	unknown(trace,fail).
> ------------------------------------------------
> 
>  in file file002.pl':
> ------------------------------------------------ 
>  :-['file001.pl'].
>  :-set_swipl.
>  -----------------------------------------------
>  
>  Now, let's use SWIProlog version 3.2.8 to load 'file002.pl' and invoke
>  gensym(a,P). It returns 
>  
>  --------------------
>  ?- gensym(a,P).
> 
> P = a1 
> 
> Yes
> ?- 
> ---------------------
> 
> Then, use version 3.4.1 (or later), we have 
> 
> ---------------------
> ?- gensym(a,P).
> 
> No
> ?- 
> --------------------
> 
> This could be one of my problems.
> Any idea?

Yes.  The difference is that gensym/2 used to be built-in and is now
a library predicate (from library(gensym)).  As you switch handling
unknown predicates to `fail', it will not try to do autoloading and
thus misses the definition of gensym/2.  Due to the same flag you
get a simple `No'.

You can fix this by loading gensym/2 by hand using

	:- use_module(library(gensym)).

Better, NEVER set handling unknown predicates to fail.  Declare 
predicates that might be called when they are not defined dynamic
or multifile.

	--- Jan