guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Per-module reader, take #2


From: Neil Jerram
Subject: Re: [PATCH] Per-module reader, take #2
Date: Sun, 30 Oct 2005 19:55:19 +0000
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Neil Jerram <address@hidden> writes:

> Another detail that needs thought is whether any of the stack of load
> procedures defined in r4rs.scm and boot-9.scm (load-from-path, load
> and load-module) need enhancing to take a reader arg.

The stack of load procedures is...

 primitive-load, defined in load.c

 `load' defined in r4rs.scm, which boot-9.scm then renames as
 `basic-load'.  This is presumably intended to be an R4RS-compliant
 load; its implementation builds on primitive-load by setting a hook
 which can announce the file being loaded, and by starting a new stack
 (start-stack).

 `load-module' defined in boot-9.scm.  This builds on basic-load by
 adding

  - save-module-excursion, so that loading a module doesn't change the
    loader's current module

  - the ability to load files with relative path names.

Finally boot-9 does (define load load-module), so `load' ends up being
what I just described as load-module.

So one possibility for adding custom reader support to all this is...

- Don't put any current-reader framing code in primitive-load.  In
  other words, don't reset current-reader to #f (or anything else) at
  the start of primitive-load, and don't use framing to restore the
  value of the current-reader at the end if the loaded code has
  changed it.  This means that primitive-load keeps its existing
  primitiveness - i.e. it isn't much more than just a read eval loop.

- Add an optional reader arg to both r4rs's load and boot-9's
  load-module, and treat as #f if not specified.  In r4rs load, do
  (with-fluids ((the-reader reader)) ...) around the existing code.  In
  load-module, just pass the reader through to basic-load.

This would preserve existing behaviour for any calls to load or
use-modules, which are the mainline cases, even when the caller has
installed a non-default reader, but it also allows developers to
achieve different behaviour when they want it by using primitive-load
and the optional reader arg to load.

This can also be seen as analogous to how primitive-eval allows
(current-module) to change, but eval doesn't.

Regards,
        Neil





reply via email to

[Prev in Thread] Current Thread [Next in Thread]