summaryrefslogtreecommitdiff
path: root/MLKFloat.m
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-06-16 11:02:11 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-06-16 11:02:11 +0200
commitcddf492efdf7e44b26a0093fced5673a78c2fd28 (patch)
treee0f9d4efe7676bbcfa3029b2969b87246823c9c8 /MLKFloat.m
parentce205cc7273a031ed6bbde71ba340a7996de6d5d (diff)
MLKFloat: Explicitly declare the contract for subclasses.
Diffstat (limited to 'MLKFloat.m')
-rw-r--r--MLKFloat.m26
1 files changed, 25 insertions, 1 deletions
diff --git a/MLKFloat.m b/MLKFloat.m
index 4083146..4fc2144 100644
--- a/MLKFloat.m
+++ b/MLKFloat.m
@@ -21,6 +21,7 @@
#import "MLKDoubleFloat.h"
#import "MLKPackage.h"
#import "MLKDynamicContext.h"
+#import "MLKError.h"
@implementation MLKFloat : MLKLispValue
@@ -32,9 +33,13 @@
exponentNegative:(BOOL)exponentNegative
{
MLKSymbol *defaultFormat;
- MLKPackage *cl = [MLKPackage findPackage:@"COMMON-LISP"];
+ MLKPackage *cl;
+
+ cl = [MLKPackage findPackage:@"COMMON-LISP"];
defaultFormat = [[MLKDynamicContext currentContext]
valueForBinding:[cl intern:@"*READ-DEFAULT-FLOAT-FORMAT*"]];
+
+ // FIXME: Shouldn't the readtable decide which exponent markers do what?
if (exponentMarker == 'd' || exponentMarker == 'D'
|| exponentMarker == 'l' || exponentMarker == 'L'
|| ((exponentMarker == 'e' || exponentMarker == 'E')
@@ -52,4 +57,23 @@
exponent:exponent
exponentNegative:exponentNegative];
}
+
+#define DECLARE_ABSTRACT(SIGNATURE, RETURN_VALUE) \
+ SIGNATURE \
+ { \
+ [[MLKError errorWithMessage:@"Tried to invoke an abstract method."] raise]; \
+ return RETURN_VALUE; \
+ }
+
+DECLARE_ABSTRACT (-(float) floatValue, 0.0)
+DECLARE_ABSTRACT (-(double) doubleValue, 0.0)
+DECLARE_ABSTRACT (-(MLKFloat *) add:(MLKFloat *)arg, nil)
+DECLARE_ABSTRACT (-(MLKFloat *) subtract:(MLKFloat *)arg, nil)
+DECLARE_ABSTRACT (-(MLKFloat *) multiplyWith:(MLKFloat *)arg, nil)
+DECLARE_ABSTRACT (-(MLKFloat *) divideBy:(MLKFloat *)arg, nil)
+
+-(NSString *) description
+{
+ return [super description];
+}
@end