[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
6.1.12 Homogeneous Vectors (SRFI-4)
Bigloo fully supports SRFI-4 specification of homogeneous vectors (see http://srfi.schemers.org/srfi-4/srfi-4.html).
Each homogeneous vector is represented by a Bigloo type. That is:
-
::s8vector
signed exact integer in the range -(2^7) to (2^7)-1 -
::u8vector
unsigned exact integer in the range 0 to (2^8)-1 -
::s16vector
signed exact integer in the range -(2^15) to (2^15)-1 -
::u16vector
unsigned exact integer in the range 0 to (2^16)-1 -
::s32vector
signed exact integer in the range -(2^31) to (2^31)-1 -
::u32vector
unsigned exact integer in the range 0 to (2^32)-1 -
::s64vector
signed exact integer in the range -(2^63) to (2^63)-1 -
::u64vector
unsigned exact integer in the range 0 to (2^64)-1 -
f32vector
inexact small real -
f64vector
inexact largest real
Each homogeneous vector datatype has an external representation which is supported by the read and write procedures and by the program parser. Each datatype also has a set of associated predefined procedures analogous to those available for Scheme’s heterogeneous vectors.
As noted by Marc Feeley’s specification, for each value of TAG in { s8, u8, s16, u16, s32, u32, s64, u64, f32,f64 }, if the datatype TAGvector is supported, then
- the external representation of instances of the datatype TAGvector
is #TAG( ...elements... ).
For example,
#u8(0 #e1e2 #xff)
is an u8vector of length 3 containing 0, 100 and 255;#f64(-1.5)
is an f64vector of length 1 containing -1.5.Note that the syntax for float vectors conflicts with Standard Scheme which parses
#f32()
as 3 objects:#f
,32
and()
. For this reason, conformance to this SRFI implies this minor nonconformance to Standard Scheme.This external representation is also available in program source code. For example,
(set! x '#u8(1 2 3))
will set x to the object#u8(1 2 3)
. Literal homogeneous vectors must be quoted just like heterogeneous vectors must be. Homogeneous vectors can appear in quasiquotations but must not contain unquote or unquote-splicing forms (i.e.`(,x #u8(1 2))
is legal but`#u8(1 ,x 2)
is not). This restriction is to accomodate the many Scheme systems that use the read procedure to parse programs. - the following predefined procedures are available:
- SRFI-4 procedure: TAGvector? obj
- SRFI-4 procedure: make-TAGvector n [ TAGvalue ]
- SRFI-4 procedure: TAGvector TAGvalue ...
- SRFI-4 procedure: TAGvector-length TAGvect
- SRFI-4 procedure: TAGvector-ref TAGvect i
- SRFI-4 procedure: TAGvector-set! TAGvect i TAGvalue
- SRFI-4 procedure: TAGvector->list TAGvect
- SRFI-4 procedure: list->TAGvector TAGlist
-
where obj is any Scheme object, n is a nonnegative exact integer, i is a nonnegative exact integer less than the length of the vector, TAGvect is an instance of the TAGvector datatype, TAGvalue is a number of the type acceptable for elements of the TAGvector datatype, and TAGlist is a proper list of numbers of the type acceptable for elements of the TAGvector datatype.
It is an error if TAGvalue is not the same type as the elements of the TAGvector datatype (for example if an exact integer is passed to f64vector). If the fill value is not specified, the content of the vector is unspecified but individual elements of the vector are guaranteed to be in the range of values permitted for that type of vector.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March 31, 2014 using texi2html 5.0.