diff options
author | Matthias Andreas Benkard <matthias@benkard.de> | 2008-06-23 20:29:43 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <matthias@benkard.de> | 2008-06-23 20:29:43 +0200 |
commit | 85eb92df39b3825183d9a737aed0fdb3872c9241 (patch) | |
tree | aa912de97a17faa73e716f4060b9be6d8881940c | |
parent | 3aa255629a915314b71c04820833b683ff9234fc (diff) |
Allow binding NIL in environments.
-rw-r--r-- | MLKEnvironment.m | 9 | ||||
-rw-r--r-- | MLKInterpreter.m | 2 |
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"]; } |