From jan@swi.psy.uva.nl  Tue Feb 29 10:36:19 2000
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id KAA12139;
	Tue, 29 Feb 2000 10:36:19 +0100 (MET)
Received: (from jan@localhost)
	by gollem.swi.psy.uva.nl (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id KAA05136;
	Tue, 29 Feb 2000 10:36:32 +0100
Date: Tue, 29 Feb 2000 10:36:32 +0100
Message-Id: <200002290936.KAA05136@gollem.swi.psy.uva.nl>
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Subject: Re: user-defined autoload within call
To: Paul Singleton <p.singleton@keele.ac.uk>,
        SWI Prolog <prolog@swi.psy.uva.nl>
In-Reply-To: Paul Singleton's message of Mon, 28 Feb 2000 20:42:41 +0000
Phone: +31 - 20 - 525 6121

> 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

