Re: Question: cio IO predicates not "cleand up" after program aborts

From: Joachim Schimpf <>
Date: Wed 19 Jan 2005 12:36:07 PM GMT
Message-ID: <>
Ulrich Scholz wrote:
> Dear all,
> a short question:
> I'm using the cio library, which provides C-Prolog compatible I/O predicate, 
> to implement a parser.  

This is a backward compatibility library, and you should not use it for
new code.  The disadvantage of its predicates is precisely that they
change the settings of the global stream aliases 'input' and 'output',
and when something goes wrong, things are not undone.  It is cleaner
to use the standard I/O predicates with (anonymous) stream arguments
(i.e. write/2, read/2 etc).

> Sometimes it seems that if the parser aborts because of a programming mistake, 
> the input mechanism is not "cleaned up": Every odd time I start the parser, 
> I get strange errors but every other time, it is fine.
> How can I manually clean up any open file?

You can use block/3 to catch the abort and close/reset the streams
in the recovery goal.

  Joachim Schimpf              /             phone: +44 20 7594 8187
  IC-Parc                     /
  Imperial College London    /
Received on Wed Jan 19 12:39:55 2005

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:33 PM GMT GMT