port position-tracking clean-ups

Add `file-position*', which can return #f instead of raising
an exception when a port's position is unknown. Change
`make-input-port' and `make-output-port' to accept more
kinds of values as the initial position.

These changes make it possible to synchronize a port's
position with a `port-commit-peeked' action. It's ugly,
which I think reflect something broken about position
tracking in the port protocol (which seems difficult to fix
without breaking compaibility).

original commit: b61f3f751c5dfe72869fd449ba3ff42f520d0927
This commit is contained in:
Matthew Flatt 2012-08-28 13:42:02 -06:00
parent c9a754132a
commit 10d9de8b62

View File

@ -2155,6 +2155,7 @@
[(-Port (one-of/c 'none 'line 'block)) -Void])]
[file-position (cl-> [(-Port) -Nat]
[(-Port -Integer) -Void])]
[file-position* (-> -Port (Un -Nat (-val #f)))]
;Section 12.1.4
[port-count-lines! (-> (Un -Input-Port -Output-Port) -Void)]