[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-hackers] [PATCH] [5] Reject define-values outside the toplevel
From: |
Peter Bex |
Subject: |
[Chicken-hackers] [PATCH] [5] Reject define-values outside the toplevel |
Date: |
Sun, 9 Apr 2017 16:23:53 +0200 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
Hi all,
I noticed that an ill-placed "define-values" can still result in new
toplevel variables being defined.
In order to make this work without problems, I had to get rid of
"##core#define-toplevel" and replace it with a pure check.
Now the defining macros expand to something like this:
(##core#begin (##core#ensure-toplevel-definition x) (set! x y))
The ensure-toplevel-definition will check that the definition is
at toplevel and then compile down to (##core#undefined), and thus
eventually it will just disappear, so the generated code should
be identical to the original case of just a set!.
This change was necessary because whatever I tried, with the old
##core#define-toplevel I was unable to prevent a failing values producer
from resulting in the variables being (re)defined, which is definitely
not what we want.
PS: The ##core#set! hunk is so big because it fixes a bad indentation.
I went through the trouble of replacining [] by () as well, while
I'm at it. The only _real_ change is that the handling of
##core#define-toplevel is removed from that part of the code.
Cheers,
Peter
0001-Reject-define-values-in-expression-contexts.patch
Description: Text Data
signature.asc
Description: Digital signature
- [Chicken-hackers] [PATCH] [5] Reject define-values outside the toplevel,
Peter Bex <=