Minor cleanup in SYMBOL-FUNCTION

This commit is contained in:
Mike Cifelli 2017-02-27 14:54:31 -05:00
parent d3e3f52e59
commit 5129f6c17b
1 changed files with 5 additions and 5 deletions

View File

@ -25,18 +25,18 @@ public class SYMBOL_FUNCTION extends LispFunction {
LispFunction function = FunctionTable.lookupFunction(symbol.toString()); LispFunction function = FunctionTable.lookupFunction(symbol.toString());
if (function != null) if (function != null)
return createSymbolRepresentation(symbol, function); return createRepresentation(symbol, function);
throw new UndefinedSymbolFunctionException(symbol); throw new UndefinedSymbolFunctionException(symbol);
} }
private SExpression createSymbolRepresentation(SExpression symbol, LispFunction function) { private SExpression createRepresentation(SExpression symbol, LispFunction function) {
if (function instanceof UserDefinedFunction) if (function instanceof UserDefinedFunction)
return ((UserDefinedFunction) function).getLambdaExpression(); return ((UserDefinedFunction) function).getLambdaExpression();
else if (function instanceof LispSpecialFunction)
return new Symbol(MessageFormat.format("#<SPECIAL-FUNCTION {0}>", symbol.toString()));
return new Symbol(MessageFormat.format("#<FUNCTION {0}>", symbol.toString())); String typeIndicator = function instanceof LispSpecialFunction ? "SPECIAL-FUNCTION" : "FUNCTION";
return new Symbol(MessageFormat.format("#<{0} {1}>", typeIndicator, symbol));
} }
public static class UndefinedSymbolFunctionException extends LispException { public static class UndefinedSymbolFunctionException extends LispException {