This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: #!null in generic procedures
Here's a new patch. Please ignore the previous patch on this subject.
The patch below fixes using #!null as an argument to a generic
procedure, but preserves the (instance? ...) behavior.
Thanks!
Regards,
Chris Dean
Index: gnu/expr/ModuleMethod.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/expr/ModuleMethod.java,v
retrieving revision 1.6
diff -u -r1.6 ModuleMethod.java
--- gnu/expr/ModuleMethod.java 12 Nov 2001 21:42:38 -0000 1.6
+++ gnu/expr/ModuleMethod.java 8 Apr 2003 22:47:56 -0000
@@ -120,7 +120,7 @@
}
for (int i = 0; i < args.length; i++)
{
- if (! getParameterType(i).isInstance(args[i]))
+ if (args[i] != null && ! getParameterType(i).isInstance(args[i]))
return NO_MATCH_BAD_TYPE|i;
}
ctx.value1 = args;
Index: testsuite/misc-test.scm
===================================================================
RCS file: /cvs/kawa/kawa/testsuite/misc-test.scm,v
retrieving revision 1.31
diff -u -r1.31 misc-test.scm
--- testsuite/misc-test.scm 20 Nov 2002 21:40:30 -0000 1.31
+++ testsuite/misc-test.scm 8 Apr 2003 22:47:56 -0000
@@ -1,4 +1,4 @@
-(test-init "Miscellaneous" 103)
+(test-init "Miscellaneous" 108)
;;; DSSSL spec example 11
(test '(3 4 5 6) (lambda x x) 3 4 5 6)
@@ -408,10 +408,13 @@
test-read-split)
(define plus10 (make-procedure foo: 33 name: 'Plus10
- method: (lambda (x y) (+ x y 10))
+ method: (lambda (x y) (+ x
+ (if (number? y) y 0)
+ 10))
method: (lambda () 10)))
(test 50 plus10 30 10)
(test 10 plus10)
+(test 20 plus10 10 #!null)
;;(test 10 'plus10-error
;; (try-catch (plus10 3) (ex <java.lang.Exception> "error")))
(test 33 procedure-property plus10 'foo)
@@ -449,3 +452,9 @@
(test '|123| Long:toString (Long:new '00123))
(define (to-int-string x) (java.lang.Object:toString (Long:new x)))
(test '|124| to-int-string '00124)
+
+;; Test instance?
+(test #t instance? 1 <number>)
+(test #t instance? "x" <string>)
+(test #f instance? "x" <number>)
+(test #f instance? #!null <string>)