Subject: Re: user-defined autoload within call

From: Jan Wielemaker <[email-masked]>
Date: Tue, 29 Feb 2000 10:36:32 +0100

> I've tried to override the 3.3.0 autoloader with my own, thus:
> 
>   :- initialization set_feature(autoload, false).
> 
>   exception(undefined_predicate, N/A, Action) :-
>       (   write( '[autoloading '), write( N/A), write( '...]'), nl,
>           l( N)
>       ->  Action = retry
>       ;   write( '[autoload FAILED: '), write( N/A), write( ']'), nl,
>           Action = fail
>       ).
> 
> but although this works with top-level goals:
> 
>   ?- fred.
>   [autoloading fred/0...]
> 
> it doesn't get used for undefined predicates within "called" goals:
> 
>   ?- Goal = fred,
>   |    call(Goal).
>   ERROR: Undefined procedure: fred/0
> 
> whereas the default autoloader does.  Is there an easy fix for this?
> (I've not yet delved into boot/autoload.pl but I'm prepared to).

If you want to delve, you need src/pl-proc.c :-).  Better is not to
switch of the system autoloader.  Exception is called *before* the
system autoloader, but it is only called if the autoload flag is true.

Due to the do-what-i-mean, the toplevel works slightly different (this
is arguably wrong, but pretty low priority).

The name exception/3 is simply wrong and one should consider this a
(useful) things of the past.  I think it should be called
autoload_hook/2 or something like that (all other functionality has been
moved to ISO exception handling or print_message).

	Regards --- Jan