From c1e2a414b56ffd61d03cdfb0eedb7752083ea0c8 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Thu, 3 Jul 2008 20:35:48 +0200 Subject: When printing a symbol, omit the package prefix as appropriate. --- MLKSymbol.m | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'MLKSymbol.m') diff --git a/MLKSymbol.m b/MLKSymbol.m index 02cd728..36b6359 100644 --- a/MLKSymbol.m +++ b/MLKSymbol.m @@ -16,9 +16,12 @@ * along with this program. If not, see . */ +#import "MLKDynamicContext.h" +#import "MLKPackage.h" #import "MLKSymbol.h" #import "runtime-compatibility.h" +#import #import @@ -69,7 +72,35 @@ // NOTE: Need to take *PRINT-GENSYM* into account. // // FIXME: This is wrong in more than one way. - return [NSString stringWithFormat:@"|%@|::|%@|", [homePackage name], name]; + MLKPackage *currentPackage = + [[MLKDynamicContext currentContext] + valueForSymbol:[[MLKPackage findPackage:@"COMMON-LISP"] + intern:@"*PACKAGE*"]]; + BOOL accessible; + NSString *packagePrefix; + + NS_DURING + { + if ([currentPackage findSymbol:name] == self) + accessible = YES; + else + accessible = NO; + } + NS_HANDLER + { + if ([[localException name] isEqualToString:@"MLKNoSuchSymbolError"]) + accessible = NO; + else + [localException raise]; + } + NS_ENDHANDLER; + + if (accessible) + packagePrefix = [NSString string]; + else + packagePrefix = [NSString stringWithFormat:@"|%@|::", [homePackage name]]; + + return [NSString stringWithFormat:@"%@|%@|", packagePrefix, name]; } -(NSString *) description -- cgit v1.2.3