manpagez: man pages & more
info bigloo
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

27.1.6.5 C arrays

C arrays are defined by the <array-type>

<array-type> → (array <ident>)

<ident> is the name of a previously defined type. Array types are similar to pointer types except that they include their size in their type definition string. Let us suppose the array type declaration:

(type array (array ident) ...)

If ident is the name of a structure type, Bigloo automatically creates structures accessors (see section Struct and Union types). Otherwise, it creates the following functions:

Here is an example of a program using array types:

(module foo 
   (extern 
    (type double* (array double) "double [ 10 ]")))

(define (make-vect::double* x y z)
   (let ((vect (make-double*)))
      (double*-set! vect 0 x)
      (double*-set! vect 1 y)
      (double*-set! vect 2 z)
      vect))

(define (vect-norm vect::double*)
   (sqrt (+ (expt (double*-ref vect 0) 2)
	    (expt (double*-ref vect 1) 2)
	    (expt (double*-ref vect 2) 2))))


(print (vect-norm (make-vect 1.2 4.5 -4.5)))

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on March 31, 2014 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.