From 1be372285563189dba8f7ecf7b26a049f3728655 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Thu, 31 Jul 2008 12:20:07 +0200 Subject: Make keywords self-evaluate while interning, not while reading. --- MLKPackage.m | 23 +++++++++++++++++++++++ MLKReader.m | 10 ++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/MLKPackage.m b/MLKPackage.m index 2757455..3153b74 100644 --- a/MLKPackage.m +++ b/MLKPackage.m @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#import "MLKDynamicContext.h" #import "MLKPackage.h" #import "MLKSymbol.h" #import "NSObject-MLKPrinting.h" @@ -267,6 +268,17 @@ static NSMutableDictionary *packages = nil; [_accessible_symbols setObject:symbol forKey:name]; [_present_symbols addObject:symbol]; + + if ([_name isEqual:@"KEYWORD"]) + { + // Make keyword symbols self-evaluate. + [[MLKDynamicContext globalContext] addValue:symbol forSymbol:symbol]; + + // Make them external as well. + [self export:symbol]; + + // FIXME: Should finally make them constant, see CLHS 10.2, Type KEYWORD. + } } -(void) inherit:(MLKSymbol *)symbol @@ -290,6 +302,17 @@ static NSMutableDictionary *packages = nil; [self descriptionForLisp]]; [_accessible_symbols setObject:symbol forKey:name]; + + if ([_name isEqual:@"KEYWORD"]) + { + // Make keyword symbols self-evaluate. + [[MLKDynamicContext globalContext] addValue:symbol forSymbol:symbol]; + + // Make them external as well. + [self export:symbol]; + + // FIXME: Should finally make them constant, see CLHS 10.2, Type KEYWORD. + } } -(void) uninherit:(MLKSymbol *)symbol diff --git a/MLKReader.m b/MLKReader.m index a6f11c1..abd8a43 100644 --- a/MLKReader.m +++ b/MLKReader.m @@ -522,20 +522,14 @@ readingUninternedSymbol:(BOOL)readingUninternedSymbol else symbol = [MLKSymbol symbolWithName:symbolName package:nil]; - if (packageMarker == 0) - { - // Make keyword symbols self-evaluate. - [[MLKDynamicContext globalContext] addValue:symbol forSymbol:symbol]; - } - return symbol; } } +(id) readFromString:(NSString *)string { - return [self readFromStream:[[MLKStringInputStream alloc] - initWithString:string] + return [self readFromStream:AUTORELEASE([[MLKStringInputStream alloc] + initWithString:string]) eofError:YES eofValue:nil recursive:NO -- cgit v1.2.3