[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-hackers] [PATCH] Use current environment in code walkers, causi
From: |
Peter Bex |
Subject: |
[Chicken-hackers] [PATCH] Use current environment in code walkers, causing "import" to be lexically scoped (fixes the remainder of #1437) |
Date: |
Sat, 28 Apr 2018 23:17:27 +0200 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
Hi all,
While figuring out what was causing the remaining issue in #1437, I found
out that a proper fix would be to change the code walker to always
dereference ##sys#current-environment for every lookup. Attached is a
pretty large, but straightforward patch to do this.
The patch basically drops the "se" argument of "walk" in both the
compiler and the interpreter. Any procedure that requires a syntax
environment argument is now called with (##sys#current-environment),
and anywhere the syntax environment is (functionally) modified, we
parameterize (##sys#current-environment) before calling walk recursively.
As a cool side effect, the fix accidentally adds a new feature: (import)
is now lexically scoped (like Python's import, but better).
For instance,
(begin
(let ()
(import (rename scheme (- +)))
(print (+ 1 2)))
(print (+ 1 2)))
will now print "-1", followed by "3".
Cheers,
Peter
0001-Change-module-imports-to-be-lexically-scoped.patch
Description: Text Data
signature.asc
Description: PGP signature
- [Chicken-hackers] [PATCH] Use current environment in code walkers, causing "import" to be lexically scoped (fixes the remainder of #1437),
Peter Bex <=