How to do line oriented i/o in constant space?

Klacke klacke@REDACTED
Wed Oct 11 10:13:33 CEST 2000


On Mon, Oct 09, 2000 at 03:39:19PM +0100, Sean Hinde wrote:
> > > A middle way would be 
> > > to get binaries and then convert to lists as required.
> > > 
> > 
> > 
> > Possibly.
> 
> So what would be the efficient way to do this?
> 
> Sean


It would be to open a Port to the io channel, receive binary messages from
the Port, and then either use the Bitsyntax or appropriate binary_to_lists's 
to pull the binary object apart.

This is how we typically do socket and file programming  in erlang
today. A similar approach is indeed possible with stdin/stdout 
using the open_port({fd, 0, 1 .... approach.

So the io: routines are nice if a high degree of flexibility
is needed and the performance requirements are low, whereas the
direct port mechanism is better if performance is important.
A nice example where a high degree of flexibility is needed is 
the erlang shell. This was also the first application which used the 
io: routines and ... the io: routines were designed to cope with
the requirements of the shell.

/klacke



-- 
Claes Wikstrom                          <klacke@REDACTED>
Bluetail AB                             http://www.bluetail.com





More information about the erlang-questions mailing list