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

From: Felix Klock's plt proxy (pltscheme at pnkfx.org)
Date: Fri Jan 16 17:03:10 EST 2004


Alright, I've been writing some code that loads and evaluates 
expressions from a file that has some Scheme code intermixed with other 

In the process, I have encountered some problems with the interactions 
between (file-position port k) and (read-syntax ...)

Specifically, it seems like when you change the file position, and then 
do read-syntax, read-syntax acts like the stream has not been changed, 
and continues assigning location numbers incrementally.

Here is a small test case that exposes the problem:

(let ((fname "isolate-test-file-2")
       (so->d syntax-object->datum))
   (call-with-output-file fname
     (lambda (output)
       (write '(car '(a b c)) output)))
   (call-with-input-file fname
     (lambda (input)
       (let ((R (lambda () (read-syntax fname input))))
         (let* ((start-pos (file-position input))
                (s1 (R)) (s1-pos (syntax-position s1)))
           (file-position input start-pos)
           (let* ((s2 (R)) (s2-pos (syntax-position s2)))
             (display `((s1: ,(so->d s1) s1-pos: ,s1-pos)
                        (s2: ,(so->d s2) s2-pos: ,s2-pos))) 

When I evaluate this expression in a directory with no 
"isolate-test-file-2" file, mzscheme outputs:

  ((s1: (car (quote (a b c))) s1-pos: 1) (s2: (car (quote (a b c))) 
s2-pos: 22))

But I would really prefer to see s2-position equal 1.  Otherwise the 
DrScheme debugger goes totally off course when displaying source for 
the stack trace.

Any thoughts?


"please get back under the porch before
one of the neighbors sees you"  -www.redmeat.com

Posted on the users mailing list.