| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
27.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-arwhich is a function of one integer argument. - a predicate named
ar?. - a getter named
ar-refwhich 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 October 23, 2011 using texi2html 5.0.
