summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-06-23 20:29:43 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-06-23 20:29:43 +0200
commit85eb92df39b3825183d9a737aed0fdb3872c9241 (patch)
treeaa912de97a17faa73e716f4060b9be6d8881940c
parent3aa255629a915314b71c04820833b683ff9234fc (diff)
Allow binding NIL in environments.
-rw-r--r--MLKEnvironment.m9
-rw-r--r--MLKInterpreter.m2
2 files changed, 8 insertions, 3 deletions
diff --git a/MLKEnvironment.m b/MLKEnvironment.m
index 2dab2aa..581c462 100644
--- a/MLKEnvironment.m
+++ b/MLKEnvironment.m
@@ -74,7 +74,9 @@ static id UNBOUND;
-(void) setValue:(id)value forBinding:(MLKSymbol *)symbol;
{
- [self setBinding:symbol to:value inEnvironment:self];
+ [self setBinding:(symbol ? (id)symbol : (id)[NSNull null])
+ to:value
+ inEnvironment:self];
}
-(void) setBinding:(MLKSymbol *)symbol to:(id)value inEnvironment:(MLKEnvironment *)env
@@ -93,7 +95,8 @@ static id UNBOUND;
-(id) valueForBinding:(MLKSymbol *)symbol
{
- return [self valueForBinding:symbol inEnvironment:self];
+ return [self valueForBinding:(symbol ? (id)symbol : (id)[NSNull null])
+ inEnvironment:self];
}
-(id) valueForBinding:(MLKSymbol *)symbol inEnvironment:(MLKEnvironment *)env
@@ -134,7 +137,7 @@ static id UNBOUND;
-(void) addBinding:(MLKSymbol *)symbol
{
- [_bindings setObject:UNBOUND forKey:symbol];
+ [_bindings setObject:UNBOUND forKey:(symbol ? (id)symbol : (id)[NSNull null])];
}
-(MLKEnvironment *) environmentForBinding:(MLKSymbol *)symbol
diff --git a/MLKInterpreter.m b/MLKInterpreter.m
index 1f158ec..a8b94ee 100644
--- a/MLKInterpreter.m
+++ b/MLKInterpreter.m
@@ -48,6 +48,7 @@ static MLKSymbol *FUNCALL;
static MLKSymbol *EVAL;
static MLKSymbol *QUOTE;
static MLKSymbol *SETQ;
+static MLKSymbol *PROGV;
static MLKSymbol *_DEFMACRO;
@@ -69,6 +70,7 @@ static MLKSymbol *_DEFMACRO;
EVAL = [cl intern:@"EVAL"];
QUOTE = [cl intern:@"QUOTE"];
SETQ = [cl intern:@"SETQ"];
+ PROGV = [cl intern:@"PROGV"];
_DEFMACRO = [sys intern:@"%DEFMACRO"];
}