Custom ports are very useful in practice, though I still wonder if it should fit in Small Scheme. But I'll comment on the details.
From: John Cowan <[email protected]> Subject: [r6rs-discuss] New features for small Scheme, part 7 bis: custom ports Date: Mon, 14 Sep 2009 14:21:13 -0400 > Here are the 6 standard symbols for custom input ports and their default > behaviors: > > read-char Returns an eof-object > peek-char Returns an eof-object > read-u8 Returns an eof-object > peek-u8 Returns an eof-object > port-u8-position Does nothing > set-port-u8-position! Does nothing > > Here are the 4 standard symbols for custom output ports and their > default behaviors. > > write-char Does nothing > write-u8 Does nothing > port-u8-position Does nothing > set-port-u8-position! Does nothing * Flushing output port is also frequently needed operation. * How about close? Sometimes you need to release some resource upon closure of the custom port. * If we have a close operation, should it be invoked when the port is GCed? * I'm a bit worried about it's mutation-based API. Will we ever need to alter those procedures in middle of port operation? If such change is foreseen by the port implementor, he can put such switch mechanism into the initial procedure. The only weak advantage I can think of is for debugging. OTOH, the fact that these operations can be changed at any time may complicate efficient implementation (any high-level I/O operations has to check whether the low-level op is altered or not for each character/byte.) If we don't need to change those procedures once they're set, then it's clearer that we make them immutable, and give them at construction time. --shiro _______________________________________________ r6rs-discuss mailing list [email protected] http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss
