From vannoord@let.rug.nl  Tue Nov  2 22:35:15 1999
Received: from froh.let.rug.nl (vannoord@froh.let.rug.nl [129.125.8.25])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id WAA07287;
	Tue, 2 Nov 1999 22:35:15 +0100 (MET)
Received: (from vannoord@localhost)
	by froh.let.rug.nl (8.9.3/8.9.3) id WAA24416;
	Tue, 2 Nov 1999 22:35:19 +0100 (MET)
From: "Noord G.J.M. van" <vannoord@let.rug.nl>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Date: Tue,  2 Nov 1999 22:35:18 +0100 (MET)
To: Jan Wielemaker <jan@swi.psy.uva.nl>
Cc: prolog@swi.psy.uva.nl
Subject: Re: exception/3
In-Reply-To: <199911022105.WAA14768@gollem.swi.psy.uva.nl>
References: <199911022105.WAA14768@gollem.swi.psy.uva.nl>
X-Mailer: VM 6.43 under 20.4 "Emerald" XEmacs  Lucid
Message-ID: <14367.21752.259865.528892@froh.let.rug.nl>

Jan Wielemaker writes:
 > > 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.

well, in some cases it is. Reading my original message, I note I was
not providing the correct example. In some cases exception/3 is fired,
produces a message defined by me, the user. And after that swi 
prints its own message as well.

 > 
 > 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).

yes. I read that. I don't like it :-).  I want to be able to specify
only a few predicates for which I want the program to fail silently. For
most predicates, however, I do want an error to be raised. In SICStus
there's unknown_predicate_handler which can be used for this.


 > > 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.

In this application, errors are represented as fsa_error(Format,Args)
where Format,Arg is a pair of arguments normally accepted by
format/2.
Since I can use sformat and then converse the result back to an
atom I can do:

prolog:message(fsa_error(Format,Args)) -->
    { format_to_chars(Format,Args,Chars),
      atom_chars(Atom,Chars)
    },
    [Atom].

where format_to_chars is:

format_to_chars(Format,Args,Chars) :-
    sformat(String,Format,Args),
    string_to_list(String,Chars).

this prints WARNING: ..; but I'd prefer `ERROR' or some such.
Well I guess for now this suffices.



Another issue, I am having trouble getting the qsave_state/2 predicate 
to work. If I use the stand_alone option, then apparantly the
resulting saved state doesn't seem to contain any of my predicates:

1 ?- [user].
|: x :- format("hallo~n",[]).
|:
user compiled, 0.00 sec, 600 bytes. 


Yes
2 ?- qsave_program(hallo,[stand_alone(true)]).

Yes
3 ?-
[halt]
tyr:Install6 709% ./hallo
Welcome to SWI-Prolog (Version 3.2.9)
Copyright (c) 1993-1999 University of Amsterdam.  All rights reserved.

For help, use ?- help(Topic). or ?- apropos(Word).

1 ?- x.
[WARNING: Undefined predicate: `x/0']

No

Any ideas? (remember this is HP-UX 10.20; compiled with 
--disable-mapped-stacks)


If I use the default settings, then it works for small examples, but
for larger examples I get:

[FATAL ERROR:
        Could not allocate memory: Not enough space]

What can be done about that?

-- 
Gertjan van Noord Alfa-informatica, RUG,  Postbus 716, 9700 AS Groningen
vannoord at let dot rug dot nl            http://www.let.rug.nl/~vannoord/

