[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
28.4.5 Declaring Java arrays
Java arrays may be allocated and used inside Scheme code. The syntax of a Java array module clause is:
<array-clause> →(array
<ident> <typed-ident>)
The <typed-ident> must refer to the name of an existing type (i.e., a
primitive Bigloo type, a Bigloo class, an already defined Java class or
an already defined Java array). For an array named ar
, Bigloo
generates:
- a creator named
make-ar
which is a function of one integer argument. - a predicate named
ar?
. - a getter named
ar-ref
which is a function of one integer argument. - a setter named
ar-set!
which is a function of two arguments, an integer and a value of the array item types. - a length named
ar-length
.
Example:
(module foo (java (array int* ::int) (class bar (method static hello::int (::int*) "hello") "bar")) (main main)) (define (main argv) (let ((tab (make-int* 2))) (int*-set! tab 0 3) (int*-set! tab 1 6) (print (bar-hello tab))))
This document was generated on March 31, 2014 using texi2html 5.0.