It would seem to me that having stdin sent to a process of your choice is definitely more "erlangy" than doing file:reads (if there was some back pressure). But using open_port still seems a little bit dirty to me... :-) It might be a bit difficult to explain to a newbie and also has the added disadvantage of using extra command line options (-user as in Ulfs example at the shootout).
<br><br>Perhaps this could be improved with a a wrapper module, e.g. <br>stdio:set_listener(Pid, [{line, L}, binary, ...]), <br>stdio:set_options([{max_messages, M}, ..], <br>stdio:out(Binary|String)<br><br>All the same, the "stdin/stdout as files" approach is probably easier to implement in the emulator. While I am still in wishing mode
<br>I guess I would like to have a file:readln(Fd)->Bin|List as well for files in raw mode. <br><br>I know that OTP are quite conservative/careful in introducing new code, (and since we are using in commercial products we are of course thankful for that!). Is there any chance of getting any of the two above methods included?
<br><br>By the way, I also did some measurements on the newly introduced escript and it is really fast! (io_test2 is the iofile() example from above)<br><br>$ time ../io_test2.erl < ../fasta-out > tmp2.txt <br>real
0m0.380s<br>user 0m0.192s<br>sys 0m0.184s<br><br>As a reference... (I guess it does not get faster than 'cat'. look, no user...)<br>$ time cat ../fasta-out > tmp2.txt <br><br>real 0m0.128s<br>user
0m0.000s<br>sys 0m0.128s<br><br>