<razzy>
abu[m]: this (out "file" (prin (uniq (in "file" (... read ...)] erase file. i wonder if we could modify out, to open file JIT when needed. so such code would work.
<abu[m]>
I think this is not a good idea
<abu[m]>
Opening files and the lifetime of filedescriptors is such a basic thing
<abu[m]>
And it would not be possible. What if the file is bigger than memory?
<abu[m]>
What you *can* do is (out "+file" ...
<abu[m]>
Without "+", the file is opened for writing, so it truncates the file and starts to write. Changing this general principle would break almost every program
<abu[m]>
It is under the control of the programmer. What you want to do above is: (and (in "file" (read)) (out "file" (println (uniq @]
<razzy>
abu[m]: I did not known files are checked for size before opening. it seems not usefull
<abu[m]>
Why do you think the size is checked?
<razzy>
abu[m]: you said: what if file is bigger than memory. i assumed that filesize is important and checked somewhere.
<abu[m]>
No, I mean if you wait in "out" then you cannot write during that time, and memory may get full from all the reading.
<abu[m]>
'out' and 'in' are *streams*
<razzy>
i like streams. is uniq also stream?
<abu[m]>
No, uniq is a function taking a list
<abu[m]>
With "streams" I meant I/O steams here
<razzy>
so, i am thinking. if (out) wait for first uniq data, (in) is already finished reading.
<abu[m]>
This can't be implemented in a useful way. What is bad about first (in ...) and then (out ...) above?
<abu[m]>
In other cases, the standard way (not only in PicoLisp but *any* programming) is to use an temporary file
<razzy>
nothing wrong. only less pretty :] I used local variable.
<abu[m]>
I recommend you try to implement your version of 'out'
<razzy>
good advice :]
<razzy>
i am not ciricising picolisp :]
<abu[m]>
Yes, I did not think so
<abu[m]>
Opening, reading and writing files are fundamental operations though. I think they should not be messed up.