From: Alaric Snell-Pym <[email protected]> Subject: Re: [r6rs-discuss] Proposed features for small Scheme, part 2 bis: I/O Date: Wed, 23 Sep 2009 09:45:20 +0100
> > I'm not sure about port-u8-position and set-port-u8-position!. > > They are necessary for practical applications, but they seem > > to put more semantics on ports; without them, the ports are > > simply modelled as read-once/write-once stream of bytes or > > characters. > > It might be "more schemeish" to have a clone-port operation instead. > Get the port to be where you want it, and clone it, then you can go > back and read from the clone to return to that position. It's semantically clean, but the implementation gets complicated for write operations when buffering is involved. Considering the scope of small Scheme, I think it's better to leave it to srfis. For reading, I do prefer dealing with lazy streams rather than stateful ports, though. > > On having a fresh port "ambiguous" and the first operation > > determines binary/character: It does seem tricky. I'm ok > > with that, but it may be problematic on a hypothetical system > > where you have to specify whether binary or text mode at > > opening the system resource. > > The actual open can be done lazily, though That means you cannot detect failure of opening the port until the first read/write operation. It also prohibits some tricks such as opening a file in priviledged user then setuid to drop the priviledge, or opening a file for read and write then unlink the file so that the file can be used as an anonymous temporary out-of-core storage. These can be addressed by issuing dummy peek-char or peek-u8 immediately after opening operation. The question is: can we ask portable Scheme code writers to consider the possibility that the port may be opened lazily? (I'm not sure; maybe we can.) --shiro _______________________________________________ r6rs-discuss mailing list [email protected] http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss
