[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] Bidirectional ports and port-open?



On 2012-07-01, at 6:54 PM, Per Bothner wrote:

> On 06/30/2012 09:19 PM, Marc Feeley wrote:
>> Bidirectional ports may be useful to represent operating devices such
>> as serial ports, terminals, and network connections.
> 
> Such "ports" are two independent input and output ports, with
> no real interaction between the sub-ports.  So why is the concept
> of a "bidirectional port" useful in this case?
> 
> An true bi-directional port is one where you can read a "record",
> modify it, and write it back.  If the port is seekable, the input
> and output positions are tied.  Only binary (not text) is likely
> to be meaningful, though in theory you could have other port kinds.
> (A "port" is basically an abstract array with a current position,
> plus various operations that update the array or position.)

I also expect a bidirectional port when doing

   (open-file "/dev/tty")

and

  (open-tcp-client "google.com:80")

It is conceivable, but non-trivial, to arrange for these procedures to return 2 values: an input port and an output port (some Scheme systems do this), but then it becomes bothersome to pass these two values around consistenty (unless of course you cons them together, in which case you basically have an ad-hoc bidirectional port!).

Marc


_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports