[plt-scheme] changes to file-position aren't captured by read-syntax ?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Feb 5 11:49:01 EST 2004

At Thu, 22 Jan 2004 11:39:28 -0500, "Felix Klock's plt proxy" wrote:
> Here is a test program that exposes a problem with the approach you 
> recommend: I cannot repeatedly use port-next-position to decide where I 
> am in the file after I've done some backtracking with file-position, 
> because port-next-position returns values based on what the stream has 
> output.

Yes, that's true.

> (As an alternative approach, I am guessing that instead of using 
> port-next-position to grab the info to pass to read-syntax, I could 
> just use file-position and pass in zeroes as the line and column 
> numbers)

Right.

I note that this works only if no other process is reading from the
same file handle. In your application, you probably know that to be the
case. But the run-time system generally doesn't know, and that's partly
the reason that source locations are defined in terms of characters
extracted from the port (thus avoiding the question).

> Also, I don't see documentation for input-port-append in the appendix 
> for MzLib... where is it documented?

It really should be there. The documentation made it into the v206
release, definitely.

> A new question: why must the offset-list argument to read-syntax 
> provide column and line number information?
> I'm not sure I want to take the time to make line and column numbers 
> work, and I know that the DrScheme stack traces can get by with only 
> position info, so why is the interface for read-syntax forcing me to 
> provide bogus line and column numbers when all I want to do is override 
> the position info for the syntax objects I read in?

Probably the offset list should support #f elements to disable the
corresponding kind of counting (if it's on). I'll put that on my
short-term list.

Matthew



Posted on the users mailing list.