From 10d9de8b6240cb801cc10d01aa6dee4141174509 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 28 Aug 2012 13:42:02 -0600 Subject: [PATCH] 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 --- collects/typed-racket/base-env/base-env.rkt | 1 + 1 file changed, 1 insertion(+) diff --git a/collects/typed-racket/base-env/base-env.rkt b/collects/typed-racket/base-env/base-env.rkt index 2cccf2f9..8ab47bc6 100644 --- a/collects/typed-racket/base-env/base-env.rkt +++ b/collects/typed-racket/base-env/base-env.rkt @@ -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)]