[plt-scheme] port -> file/line/column ?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Oct 9 10:48:02 EDT 2002

At Tue, 8 Oct 2002 01:18:01 +0400 (MSD), Kirill Lisovsky wrote:
> 1. Is it possible to turn lines-counting on for _every_ input port in a
> program (short of redefinition of 'open-input-file' and friends) ?
> I believe that the overhead will be low, in other Schemes input ports are 
> always opened in this mode...

The overhead is high for tasks that read large blocks from a file. For
example, the `copy-port' operation in the following program takes twice
as long when the fourth line is uncommented.

 (require (lib "thread.ss"))
 (define s (open-output-string))
 (define p (open-input-file (find-system-path 'exec-file)))
 ; (port-count-lines! p)
 (time (copy-port p s))

Arguably, the default could be to count lines and columns, instead of
not counting. But after tuning the I/O paths so carefully, I'm
reluctant to slow them down by default.

> 2. Any ideas about file name?

I've just changed `object-name' to return a string for input ports. For
a file input port, the string is the absolute file path.


Posted on the users mailing list.