This is the mail archive of the kawa@sourceware.cygnus.com mailing list for the Kawa project. See the Kawa home page for more information.


[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index] [Subject Index] [Author Index] [Thread Index]

Declaring function argument types




I couldn't see anything in the kawa 1.6.55 distribution explaining
exactly how one did this (I don't profess to understand the source).
So I guessed.  Please find attached an eight-line (ish) patch to
kawa.texi containing the result of my guesswork, which might if
correct save someone else the trouble.

Of course, I could just as easily have it all wrong ...

--- kawa.texi.orig	Fri Jul 24 04:05:48 1998
+++ kawa.texi	Tue Nov 10 21:26:08 1998
@@ -502,6 +502,7 @@
 * Keywords::
 * Special named constants::
 * Optional and keyword lambda parameters::
+* Type declaration in lambda parameters::
 * Logical Number Operations::
 * Strings::
 * Records::
@@ -609,7 +610,8 @@
 (The @var{string} does not include a final @code{#\:}.)
 @end defun
 
-@node Optional and keyword lambda parameters, Logical Number Operations, Keywords, Extensions
+@node Optional and keyword lambda parameters, Type declaration in lambda parameters, Keywords, Extensions
+
 @section Optional and keyword lambda parameters
 
 Kawa borrows the extended formal argument list of DSSSL:
@@ -673,7 +675,22 @@
 environment in which all the previous formal parameters have been bound.
 @end itemize
 
-@node Logical Number Operations, Strings, Optional and keyword lambda parameters, Extensions
+@node Type declaration in lambda parameters, Logical Number Operations, Keywords, Extensions
+@section Type declaration in lambda parameters
+
+A formal argument may optionally be a list @code{(@var{name} @var{type})}.
+This declares that the argument @var{name} must be of type @var{type}.
+
+@display 
+#|kawa:229|# (define (foo (a <int>)) a)
+#|kawa:230|# (foo 2)
+2
+#|kawa:231|# (foo 'a)
+Invalid parameter, should be: java.lang.String
+java.lang.ClassCastException: java.lang.String
+@end display
+
+@node Logical Number Operations, Strings, Type declaration in lambda parameters, Extensions
 @section Logical Number Operations
 
 These functions operate on the 2's complement binary representation



Daniel
-- 
                                                          dan@pentacom.co.uk