[plt-scheme] ports, make-srcloc and recursive reads

From: Dimitris Vyzovitis (vyzo at media.mit.edu)
Date: Mon Apr 23 22:20:49 EDT 2007

On Mon, 23 Apr 2007, Dimitris Vyzovitis wrote:

> On Tue, 24 Apr 2007, Matthew Flatt wrote:
>
> > Is there some other way that this shows up, though?
>
> Not that I have seen.

port-next-location is defined like this [portfun.c]:
static Scheme_Object *port_next_location(int argc, Scheme_Object *argv[])
{
  Scheme_Object *a[3];
  long line, col, pos;

  if (!SCHEME_INPUT_PORTP(argv[0]) && !SCHEME_OUTPUT_PORTP(argv[0]))
    scheme_wrong_type("port-next-location", "port", 0, argc, argv);

  scheme_tell_all(argv[0], &line, &col, &pos);

  a[0] = ((line < 0) ? scheme_false : scheme_make_integer_value(line));
  a[1] = ((col < 0) ? scheme_false : scheme_make_integer_value(col));
  a[2] = ((pos < 0) ? scheme_false : scheme_make_integer_value(pos+1));

  return scheme_values(3, a);
}

So it can conceivably be triggered by ports that have 0s at line/col/pos
in plain reads.

-- vyzo



Posted on the users mailing list.