[erlang-questions] input too fast

Fredrik Svahn fredrik.svahn@REDACTED
Fri Jun 29 22:44:34 CEST 2007

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

Perhaps this could be improved with a a wrapper module, e.g.
stdio:set_listener(Pid, [{line, L}, binary, ...]),
stdio:set_options([{max_messages, M}, ..],

All the same, the "stdin/stdout as files" approach is probably easier to
implement in the emulator. While I am still in wishing mode
I guess I would like to have a file:readln(Fd)->Bin|List as well for files
in raw mode.

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

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)

$ time ../io_test2.erl < ../fasta-out > tmp2.txt
real    0m0.380s
user    0m0.192s
sys     0m0.184s

As a reference... (I guess it does not get faster than 'cat'. look, no
$ time cat ../fasta-out > tmp2.txt

real    0m0.128s
user    0m0.000s
sys     0m0.128s
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070629/de57c76f/attachment.htm>

More information about the erlang-questions mailing list