I/O example

Zuurbier, E. - AMSXE Erik.Zuurbier@KLM.NL
Fri, 22 Jan 1999 09:13:30 +0100


>> Also, your comment about "I want to read it into a list because it's
>> small" (or something to that effect) requires further examination--think
>> in terms of lazy evaluation. The WHOLE list of input may never need to 
>> exist all at once (as long as it's unique). So the size of the input 
>> doesn't matter.

I don't think uniqueness has anything to do with it. What is important, is
whether munge (I did not find it in my dictionary so I suppose it could be
any function) needs the last character of the input file before it can
compute the first character of the output file.

>1) read a file into a list of chars.
>2) munge the list a bit.
>3) write the list out to another file.

>If step 1) is done lazily then there is a potential problem -- namely
>that step 3) overwrites the file I am reading from, making a mess.

>Or does Clean avoid this
>problem without losing laziness, by not allowing a write to a file that
>is already open for a read?

> You wrote 3) write the list out to ANOTHER file. If it is really a
> different file, you won't overwrite anything. If it is the physically
> the same file, you will (I think) get a file error when you try to open it
> the second time.
> 
Why don't you try it?

Erik Zuurbier