Re: Type strategy for Scheme
Per Bothner 20 Nov 2022 22:57 UTC
On 11/20/22 13:59, Panicz Maciej Godek wrote:
> Currently (to my knowledge) Kawa does not support type parameters; it only provides a type called procedure that can be used to mark that something is a procedure, or a type called list to mark that something is a list.
Actually, Kawa does have type parameters:
https://www.gnu.org/software/kawa/Parameterized-Types.html
For example:
promise[pair] ;; a promise that forces to a pair.
array[int] ;; an array of unspecified rank of (32-bit signed primitive) integers
array2[complex] ;; a rank-2 array of complex numbers
java.lang.List[java.lang.String] ;; same as Java's java.lang.List<java.lang.String>
Usage example:
(define (foo1 x::array2 i::int) (x i))
emits the diagnostic:
errors-arr.scm:2:3: warning - array has rank 2 but there are 1 indexes
--
--Per Bothner
xxxxxx@bothner.com http://per.bothner.com/