From jan@swi.psy.uva.nl  Tue Nov  2 22:05:31 1999
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.114.15])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id WAA06199;
	Tue, 2 Nov 1999 22:05:31 +0100 (MET)
Received: (from jan@localhost)
	by gollem.swi.psy.uva.nl (8.9.3/8.9.3) id WAA14768;
	Tue, 2 Nov 1999 22:05:32 +0100
Date: Tue, 2 Nov 1999 22:05:32 +0100
Message-Id: <199911022105.WAA14768@gollem.swi.psy.uva.nl>
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Subject: Re: exception/3
To: "Noord G.J.M. van" <vannoord@let.rug.nl>, prolog@swi.psy.uva.nl
In-Reply-To: Noord G.J.M. van's message of Tue,  2 Nov 1999 20:42:33 +0100 (MET)
Phone: +31 - 20 - 525 6121

> why doens't exception work the way it is described in the manual?
> (version 3.2.9 on HP-UX 10.20)

Maybe this should be called maintenance problems.  One might also
call is improved understanding :-)

Thanks fot noting, but the undefined_predicate interception is no
longer called.

Undefined predicates are ignored if the unknown/2 flag is active for
the implied module (or the predicate is defined using dynamic/1) and
otherwise cause an exception in the ISO-sense (i.e. using throw/1).

> to exception/3 at all ??? (Is there a difference between an
> undefined predicate and an undefined procedure?)

No :-)

> Yes
> 7 ?- jan.
> [WARNING: Undefined predicate: `jan/0']

This works a little different as the toplevel tries to correct the
goal (DWIM) and if this fails it just prints a message.  Maybe it
should call the undefined predicate nevertheless to get consistent
behaviour to the user.

> 8 ?- [user].
> 2 |: jan :- piet.
> 2 |:
> user compiled, 0.00 sec, 0 bytes.
> 
> Yes
> 9 ?- jan.
> [WARNING: Undefined procedure: piet/0]
>    Exception: (  8) piet ?                       

This is the normal behaviour of a running program.

> Another question, is there a way to `hook' print_message/2 so that
> I can provide message printers for my own exceptions?

You can define additional translation to textual representation by
adding clauses to prolog:message/3 (a multifile predicate):

:- multifile prolog:message/3.

prolog:message(i_do_not_like(X)) -->
	[ 'I no not like ', X ].

should produce a nice message if I do throw(i_do_not_like(fortran)).

See boot/messages.  At the moment there is no dynamic hook into
print_message/2.  If you need it, please let me know.

	--- Jan

