|  | 
This chapter presents the Bigloo standard library. Bigloo is mostly
R5RS compliant but it proposes many extensions to this standard.
In a first section (Scheme Library )
the Bigloo R5RS support is presented. This section also contains various
function that are not standard (for instance, various functions used
to manage a file system). Then, in the following sections
(Serialization , Bit Manipulation , and System Programming 
Bigloo specific extensions are presented. Bigloo input and output facilities
constitute a large superset of the standard Scheme definition. For this
reason they are presented in a separate section (Input and Output ).
 
When the definition of a procedure or a special form is the
same in Bigloo and Scheme, we just mention its name;
otherwise, we explain it and qualify it as a ``bigloo
procedure''.
 
The standard boolean objects are  #t and  #f.
Note: the empty list is true. 
| notreturns #t ifobjis false, and returns#fotherwise.
 
 
| (not #t)                               => #f
(not 3)                                => #f
(not (list 3))                         => #f
(not #f)                               => #t
(not '())                              => #f
(not (list))                           => #f
(not 'nil)                             => #f
 |  |  
| 
| boolean?  obj | library procedure |  Boolean?returns #t ifobjis either #t or
#f and returns #f otherwise.
 
 
| (boolean? #f)                          => #t
(boolean? 0)                           => #f
(boolean? '())                         => #f
 |  |  | 6.1.2 Equivalence predicates
 | 
| eqv?andeq?are equivalent in Bigloo.
 
 
Since Bigloo implements| (eq? 'a 'a)                            =>  #t
(eq? '(a) '(a))                        =>  unspecified
(eq? (list 'a) (list 'a))              =>  #f
(eq? "a" "a")                          =>  unspecified
(eq? "" "")                            =>  unspecified
(eq? '() '())                          =>  #t
(eq? 2 2)                              =>  unspecified
(eq? #\A #\A)                          =>  unspecified
(eq? car car)                          =>  #t
(let ((n (+ 2 3)))
  (eq? n n))                           =>  unspecified
(let ((x '(a)))
  (eq? x x))                           =>  #t
(let ((x '#()))
  (eq? x x))                           =>  #t
(let ((p (lambda (x) x)))
  (eq? p p))                           =>  #t
 |  eqv?aseq?, the behavior is not
always conforming to R5RS.
| (eqv? 'a 'a)                           =>  #t
(eqv? 'a 'b)                           =>  #f
(eqv? 2 2)                             =>  #t
(eqv? '() '())                         =>  #t
(eqv? 100000000 100000000)             =>  #t
(eqv? (cons 1 2) (cons 1 2))           =>  #f
(eqv? (lambda () 1)
      (lambda () 2))                   =>  #f
(eqv? #f 'nil)                         =>  #f
(let ((p (lambda (x) x)))
  (eqv? p p))                          =>  unspecified
 |  
 The following examples illustrate cases in which the above rules do
not fully specify the behavior of eqv?.  All that can be said
about such cases is that the value returned by eqv? must be a
boolean.
 
 
 
| (eqv? "" "")                           =>  unspecified
(eqv? '#() '#())                       =>  unspecified
(eqv? (lambda (x) x)
      (lambda (x) x))                  =>  unspecified
(eqv? (lambda (x) x)
      (lambda (y) y))                  =>  unspecified
 (define gen-counter
  (lambda ()
    (let ((n 0))
      (lambda () (set! n (+ n 1)) n))))
(let ((g (gen-counter)))
  (eqv? g g))                          =>  #t
(eqv? (gen-counter) (gen-counter))
                                       =>  #f
(define gen-loser
  (lambda ()
    (let ((n 0))
      (lambda () (set! n (+ n 1)) 27))))
(let ((g (gen-loser)))
  (eqv? g g))                          =>  #t
(eqv? (gen-loser) (gen-loser))
                                       =>  unspecified
 
 (letrec ((f (lambda () (if (eqv? f g) 'both 'f)))
         (g (lambda () (if (eqv? f g) 'both 'g))))
  (eqv? f g))
                                       =>  unspecified
 
 (letrec ((f (lambda () (if (eqv? f g) 'f 'both)))
         (g (lambda () (if (eqv? f g) 'g 'both))))
  (eqv? f g))
                                       =>  #f
(eqv? '(a) '(a))                       =>  unspecified
(eqv? "a" "a")                         =>  unspecified
(eqv? '(b) (cdr '(a b)))               =>  unspecified
(let ((x '(a)))
  (eqv? x x))                          =>  #t
 |  |  
| 
| equal? obj1 obj2 | library procedure |  
| (equal? 'a 'a)                         =>  #t
(equal? '(a) '(a))                     =>  #t
(equal? '(a (b) c)
        '(a (b) c))                    =>  #t
(equal? "abc" "abc")                   =>  #t
(equal? 2 2)                           =>  #t
(equal? (make-vector 5 'a)
        (make-vector 5 'a))            =>  #t
(equal? (lambda (x) x)
        (lambda (y) y))                =>  unspecified
 |  |  
See r5rs, Equivalence predicates , for more details. 
The form  () is illegal .  
| 
Returns| pair-or-null? obj | bigloo procedure |  #tifobjis either a pair or the empty list. Otherwise
it returns#f. |  
| 
| set-car! pair obj | procedure |  
| set-cdr! pair obj | procedure |  |  
| 
| caar pair | library procedure |  
| cadr pair | library procedure |  
| cadar pair | library procedure |  
| caadr pair | library procedure |  
| caaar pair | library procedure |  
| caddr pair | library procedure |  
| cadar pair | library procedure |  
| cdddar pair | library procedure |  
| cddddr pair | library procedure |  |  
| 
| null? obj | library procedure |  
| list? obj | library procedure |  
| list obj ... | library procedure |  
| length list | library procedure |  
| append list ... | library procedure |  
A destructive append.| append! list ... | bigloo procedure |  |  
| 
| reverse list | library procedure |  
A destructive reverse.| reverse! list | bigloo procedure |  |  
| 
| list-ref list k | library procedure |  
| take list k | library procedure |  
| drop list k | library procedure |  
| list-tail list k | library procedure |  list-refreturns thekelement of the list.
 
 takereturns a new list made of the firstkelement of the list.
 
 Dropandlist-tailreturns the sublist oflistobtained by omitting the firstkelements. |  
| 
Returns the last pair in the nonempty, possibly improper,| last-pair list | bigloo procedure |  list. |  
| 
| memq obj list | library procedure |  
| memv obj list | library procedure |  
| member obj list | library procedure |  
| assq obj alist | library procedure |  
| assv obj alist | library procedure |  
| assoc obj alist | library procedure |  
Returns a new list which is a copy of| remq obj list | bigloo procedure |  listwith all itemseq?toobjremoved from it. |  
| 
Same as| remq! obj list | bigloo procedure |  remqbut in a destructive way. |  
| 
Returns a new list which is a copy of| delete obj list [eq equal?] | bigloo procedure |  listwith all itemsequal?toobjdeleted from it. |  
| 
Same as| delete! obj list [eq equal?] | bigloo procedure |  deletebut in a destructive way. |  
| 
Returns an object formed by consing all arguments together from right to left.
If only one| cons* obj ... | bigloo procedure |  objis supplied, thatobjis returned. |  
| 
Applies the function| every fun clist1 clist2 ... | bigloo procedure |  funacross the lists, returning the last 
non-false if the function returns non-false on every application. If 
non-false, the result ofeveryis the last value returned by the
last application offun.
 
 
| (every < '(1 2 3) '(2 3 4))            => #t
(every < '(1 2 3) '(2 3 0))            => #f
 |  |  
| 
Applies the function| any fun clist1 clist2 ... | bigloo procedure |  funacross the lists, returning non-false if the
function returns non-false for at least one application. If non-false,
the result ofanyis the first non-false value returned byfun.
 
 
| (any < '(1 2 3) '(2 3 4))            => #t
(any < '(1 2 3) '(2 3 0))            => #t
 |  |  
| 
Return the first element of| find pred clist | bigloo procedure |  clistthat satisfies predicatepred; false if no element does.
 
 
Note that| (find even? '(3 1 4 1 5 9))          => 4
 |  findhas an ambiguity in its lookup semantics -- if
find returns#f, you cannot tell (in general) if it found a#felement that satisfiedpred, or if it did not find any
element at all. In many situations, this ambiguity cannot arise --
either the list being searched is known not to contain any#felements, or the list is guaranteed to have an element satisfying
pred. However, in cases where this ambiguity can arise, you should use
find-tail instead of find -- find-tail has no such ambiguity:
 
 
|     (cond ((find-tail pred lis) => (lambda (pair) ...)) ; Handle (CAR PAIR)
          (else ...)) ; Search failed.
 |  |  
| 
Return the first pair of| find-tail pred clist | bigloo procedure |  clistwhose car satisfiespred. If no pair does, return false.
 
 find-tailcan be viewed as a general-predicate variant of the
member function.
 Examples:
 
 
 
|     (find-tail even? '(3 1 37 -8 -5 0 0)) => (-8 -5 0 0)
    (find-tail even? '(3 1 37 -5)) => #f
 ;; MEMBER X LIS:
    (find-tail (lambda (elt) (equal? x elt)) lis)
 
 In the circular-list case, this procedure "rotates" the list.
 |  |  
| 
If| reduce f ridentity list | bigloo procedure |  listif null returnsridentity, iflisthas
one element, returns that element. Otherwise, returnsfapplied to
the first element of thelistand toreduceof the rest of
the list.
 Examples:
 
 
 
|     (reduce max 0 l) <=> (apply max l)
 |  |  
| 
Returns an| make-list n [fill] | bigloo procedure |  n-element list, whose elements are all the valuefill. 
If thefillargument is not given, the elements of the list may be
arbitrary values.
 
 
| (make-list 4 'c)                     => (c c c c)
 |  |  
| 
Returns an| list-tabulate n init-proc | bigloo procedure |  n-element list. Element i of the list, where 0 <= i <n, is produced by(init-proc i). No guarantee is made about the
dynamic order in whichinit-procis applied to these indices.
 
 
| (list-tabulate 4 values)             => (0 1 2 3)
 |  |  
| 
| list-split list n [filler] | bigloo procedure |  
Split a| list-split list n [filler] | bigloo procedure |  listinto a list of lists of lengthn. Last smaller
list is filled withfiller.
 
 
| (list-split '(1 2 3 4 5 6 7 8) 3 0) => ((1 2 3) (4 5 6) (7 8 0))
(list-split (iota 10) 3)            => ((0 1 2) (3 4 5) (6 7 8) (9))
(list-split (iota 10 3) '-1)      => ((0 1 2) (3 4 5) (6 7 8) (9 -1 -1))
 |  |  
| 
Returns a list containing the elements| iota count [start step] | bigloo procedure |  
 
 
The| (start start+step ... start+(count-1)*step)
 |  startandstepparameters default to0and1, 
respectively. This procedure takes its name from the APL primitive.
 
 
| (iota 5) => (0 1 2 3 4)
(iota 5 0 -0.1) => (0 -0.1 -0.2 -0.3 -0.4)
 |  |  
| 
| list-copy l | bigloo procedure |  
The function| tree-copy l | bigloo procedure |  list-copycopies the spine of the of the list.
The functiontree-copyrecursively copies its arguments, descending
only into the list cells. |  
| 
| delete-duplicates list [eq equal?] | bigloo procedure |  
| delete-duplicates! list [eq equal?] | bigloo procedure |  delete-duplicatesremoves duplicate elements from thelistargument. If there are multiple equal elements in the argument list,
the result list only contains the first or leftmost of these elements
in the result. The order of these surviving elements is the same as in
the original list --delete-duplicatesdoes not disorder the list
(hence it is useful for "cleaning up" association lists).
 The
 equalparameter is used to compare the elements of the list;
it defaults toequal?. If x comes before y in list, then the
comparison is performed (= x y). The comparison procedure will be used
to compare each pair of elements in list no more than once; the order
in which it is applied to the various pairs is not specified.
 
 delete-duplicatesis allowed to share common tails
between argument and result lists -- for example, if the list argument
contains only unique elements, it may simply return exactly this
list. |  
See r5rs, Pairs and lists , for more details. 
Symbols are case sensitive and the reader is case sensitive too. So:
 
| (eq? 'foo 'FOO) => #f
(eq? (string->symbol "foo") (string->symbol "FOO")) => #f
 |  
Symbols may contain special characters (such as #\Newline or #\Space).
Such symbols that have to be read must be written:  |[^]+|. The
function  write uses that notation when it encounters symbols
containing special characters. 
| (write 'foo) => foo
(write 'Foo) =>Foo
(write '|foo bar|) => |foo bar|
 |  
| 
Returns the name of the symbol as a string. Modifying the string result
of| symbol->string symbol | procedure |  symbol->stringcould yield incoherent programs. It is better
to copy the string before any physical update. For instance, don't write:
See r5rs, Symbols, for more details.| (string-downcase! (symbol->string 'foo))
 |  
 but prefer:
 
| (string-downcase (symbol->string 'foo))
 |  |  
| 
| string->symbol string | procedure |  
| string->symbol-ci string | bigloo procedure |  
| symbol-append symbol ... | bigloo procedure |  String->symbolreturns a symbol whose name isstring.String->symbolrespects the case ofstring.String->symbol-cireturns a symbol whose name is(string-upcase .string)Symbol-appendreturns a 
symbol whose name is the concatenation of all thesymbol's names. |  
| 
Returns a new fresh symbol. If| gensym [obj] | bigloo procedure |  objis provided and is a string or
a symbol, it is used as prefix for the new symbol. |  
| 
Returns the property-list associated with| symbol-plist symbol-or-keyword | bigloo procedure |  symbol-or-keyword. |  
| 
Returns the value that has the key| getprop symbol-or-keyword key | bigloo procedure |  eq?tokeyfrom thesymbol-or-keyword's property list. If there is no value associated 
withkeythen#fis returned. |  
| 
Stores| putprop! symbol-or-keyword key val | bigloo procedure |  valusingkeyonsymbol-or-keyword's property list. |  
| 
Removes the value associated with| remprop! symbol-or-keyword key | bigloo procedure |  keyin thesymbol-or-keyword's
property list. The result is unspecified. |  
Here is an example of properties handling: 
| (getprop 'a-sym 'a-key)       => #f
(putprop! 'a-sym 'a-key 24)  
(getprop 'a-sym 'a-key)       => 24
(putprop! 'a-sym 'a-key2 25)  
(getprop 'a-sym 'a-key)       => 24
(getprop 'a-sym 'a-key2)      => 25
(symbol-plist 'a-sym)         => (a-key2 25 a-key 24)
(remprop! 'a-sym 'a-key)
(symbol-plist 'a-sym)         => (a-key2 25)
(putprop! 'a-sym 'a-key2 16)  
(symbol-plist 'a-sym)         => (a-key2 16)
 |  
Keywords constitute an extension to Scheme required by Dsssl [Dsssl96].
Keywords syntax is either  <ident>: or  :<ident>. Keywords are autoquote and case sensitive. So
 
The colon character ( :) does not belong to they keyword. Hence
 
| 
| keyword? obj | bigloo procedure |  
| keyword->string keyword | bigloo procedure |  
| string->keyword string | bigloo procedure |  
| keyword->symbol keyword | bigloo procedure |  
| symbol->keyword symbol | bigloo procedure |  |  
Bigloo has only three kinds of numbers: fixnum, long fixnum and
flonum.  Operations on complexes and rationals are not implemented but
for compatibility purposes, the functions  complex? and
 rational? exist.  (In fact,  complex? is the same as
 number? and  rational?  is the same as  real? in
Bigloo.) The accepted prefixes are  #b,  #o,  #d,
 #x,  #e,  #ex,  #l,  #lx,  #z,
and  #zx. For each generic arithmetic procedure, Bigloo
provides two specialized procedures, one for fixnums and one for
flonums. The names of these two specialized procedures is the name of
the original one suffixed by  fx (fixnum),  fl (flonum),
 elong (exact C long),  llong (exact C long long), and
 bx (big integer).  A fixnum has the size of a C  long
minus 2 bits. A flonum has the size of a C  double. An elong has
the size of a C long. An llong has the size of a C long long. A big
integer has an unbounded size. 
| 
| complex? x | bigloo procedure |  
| rational? x | bigloo procedure |  |  
| 
| fixnum? obj | bigloo procedure |  
These two procedures are type checkers on 
types| flonum? obj | bigloo procedure |  integerandreal. |  
| 
| elong? obj | bigloo procedure |  
The| llong? obj | bigloo procedure |  elong?procedures is a type checker for "hardware" integers, that is
integers that have the very same size has the host platform permits (e.g., 
32 bits or 64 bits integers). Thellong?procedure is a type checker
for "hardware" long long integers. Exact integers literal are introduced
with the special#eand#exprefixes. Exact long integers 
literal are introduced with the special#land#lxprefixes. |  
| 
This type checker tests if its argument is a big integer.| bignum? obj | bigloo procedure |  |  
| 
| make-elong int | bigloo procedure |  
Create an exact fixnum integer from the fixnum value| make-llong int | bigloo procedure |  int. |  
| 
| minvalelong | bigloo procedure |  
| maxvalelong | bigloo procedure |  
| minvalllong | bigloo procedure |  
Returns the minimal value (respectively the maximal value) for fix 
integers.| maxvalllong | bigloo procedure |  |  
| 
| positive? z | library procedure |  
| negative? z | library procedure |  
| zerofx? z | library procedure |  
| positivefx? z | library procedure |  
| negativefx? z | library procedure |  
| oddfx? n | library procedure |  
| evenfx? n | library procedure |  
| zerofl? z | library procedure |  
| positivefl? z | library procedure |  
| negativefl? z | library procedure |  
| oddfl? n | library procedure |  
| evenfl? n | library procedure |  
| zeroelong? z | library procedure |  
| positiveelong? z | library procedure |  
| negativeelong? z | library procedure |  
| oddelong? n | library procedure |  
| evenelong? n | library procedure |  
| zerollong? z | library procedure |  
| positivellong? z | library procedure |  
| negativellong? z | library procedure |  
| oddllong? n | library procedure |  
| evenllong? n | library procedure |  
| zerobx? z | library procedure |  
| positivebx? z | library procedure |  
| negativebx? z | library procedure |  
| oddbx? n | library procedure |  
| evenbx? n | library procedure |  |  
| 
| min x1 x2 ... | library procedure |  
| max x1 x2 ... | library procedure |  
| minfx x1 x2 ... | bigloo procedure |  
| maxfx x1 x2 ... | bigloo procedure |  
| minfl x1 x2 ... | bigloo procedure |  
| maxfl x1 x2 ... | bigloo procedure |  
| minbx x1 x2 ... | bigloo procedure |  
| maxbx x1 x2 ... | bigloo procedure |  |  
| 
| =fx i1 i2 | bigloo procedure |  
| =fl r1 r2 | bigloo procedure |  
| =elong r1 r2 | bigloo procedure |  
| =llong r1 r2 | bigloo procedure |  
| =bx r1 r2 | bigloo procedure |  
| <fx i1 i2 | bigloo procedure |  
| <fl r1 r2 | bigloo procedure |  
| <elong r1 r2 | bigloo procedure |  
| <lllong r1 r2 | bigloo procedure |  
| <bx r1 r2 | bigloo procedure |  
| >fx i1 i2 | bigloo procedure |  
| >fl r1 r2 | bigloo procedure |  
| >elong r1 r2 | bigloo procedure |  
| >lllong r1 r2 | bigloo procedure |  
| >bx r1 r2 | bigloo procedure |  
| <=fx i1 i2 | bigloo procedure |  
| <=fl r1 r2 | bigloo procedure |  
| <=elong r1 r2 | bigloo procedure |  
| <=llong r1 r2 | bigloo procedure |  
| <=bx r1 r2 | bigloo procedure |  
| >=fx i1 i2 | bigloo procedure |  
| >=fl r1 r2 | bigloo procedure |  
| >=elong r1 r2 | bigloo procedure |  
| >=llong r1 r2 | bigloo procedure |  
| >=bx r1 r2 | bigloo procedure |  |  
| 
| +fx i1 i2 | bigloo procedure |  
| +fl r1 r2 | bigloo procedure |  
| +elong r1 r2 | bigloo procedure |  
| +llong r1 r2 | bigloo procedure |  
| +bx r1 r2 | bigloo procedure |  
| *fx i1 i2 | bigloo procedure |  
| *fl r1 r2 | bigloo procedure |  
| *elong r1 r2 | bigloo procedure |  
| *llong r1 r2 | bigloo procedure |  
| *bx r1 r2 | bigloo procedure |  
| -fx i1 i2 | bigloo procedure |  
| -fl r1 r2 | bigloo procedure |  
| -elong r1 r2 | bigloo procedure |  
| -llong r1 r2 | bigloo procedure |  
| -bx r1 r2 | bigloo procedure |  
| negelong r | bigloo procedure |  
These two functions implement the unary function| negllong r | bigloo procedure |  -. |  
| 
| /fx i1 i2 | bigloo procedure |  
| /fl r1 r2 | bigloo procedure |  
| /elong r1 r2 | bigloo procedure |  
| /llong r1 r2 | bigloo procedure |  
| /bx r1 r2 | bigloo procedure |  |  
| 
| quotientelong z1 z2 | procedure |  
| quotientllong z1 z2 | procedure |  
| remainderelong z1 z2 | procedure |  
| remainderllong z1 z2 | procedure |  
| remainderfl z1 z2 | procedure |  |  
| 
| randombx z | bigloo procedure |  
the| seed-random! z | bigloo procedure |  randomfunction returns a pseudo-random integer between 0
andz.
 If no seed value is provided,  the
 randomfunction  is  automatically
seeded with a value of 1.
 The function
 randomflreturns a double in the range [0..1]. |  
| 
| exact->inexact z | procedure |  
| inexact->exact z | procedure |  
| number->string z | procedure |  
| integer->string i [radix 10] | bigloo procedure |  
| integer->string/padding i padding [radix 10] | bigloo procedure |  
| elong->string i [radix 10] | bigloo procedure |  
| llong->string i [radix 10] | bigloo procedure |  
| bignum->string i [radix 10] | bigloo procedure |  
| real->string z | bigloo procedure |  
The function| unsigned->string i [radix 16] | bigloo procedure |  integer->string/paddingconverts its arguments into
a string with a left padding filled of characters0.
 
 
The function| (integer->string/padding 3 5)       => "00003"
 |  unsigned->stringonly accepts the following radixes:2,8, and16. It converts its argument into an
unsigned representation.
 
 
| (unsigned->string 123 16)           => "7b"
(unsigned->string -123 16)          => "ffffff85"
 |  |  
| 
Returns a binary big-endian representation of the given bignum| bignum->octet-string bignum | bigloo procedure |  bignum.
 
 
|   (string-hex-extern (bignum->octet-string #zx1234567)) => "01234567"
 |  |  
| 
| double->ieee-string z | bigloo procedure |  
Returns a big-endian representation of the given number.| float->ieee-string z | bigloo procedure |  |  
| 
| string->number string [radix 10] | procedure |  
| string->real string | bigloo procedure |  
| string->elong string radix | bigloo procedure |  
| string->llong string radix | bigloo procedure |  
Bigloo implements a restricted version of| string->bignum string radix | bigloo procedure |  string->number. Ifstringdenotes a floating point number then, the only radix10may be send tostring->number. That is:
 
 
In addition,| (string->number "1243" 16)          => 4675
(string->number "1243.0" 16)        -|
# *** ERROR:bigloo:string->number
# Only radix `10' is legal for floating point number -- 16
(string->elong "234456353")         => #e234456353
 |  string->numberdoes not support radix encoded insidestring. That is:
 
 
| (string->number "#x1243")          => #f
 |  |  
| 
Counterpart to| octet-string->bignum string | bigloo procedure |  bignum->octet-string. Takes the bignum
representation in big-endian formatstringand returns the corresponding
bignum.
 
 
| (octet-string->bignum (bignum->octet-string #z1234)) => #z1234
 |  |  
| 
| ieee-string->double string | bigloo procedure |  
Convert the big-endian representations to their numeric values.| ieee-string->float string | bigloo procedure |  |  
| 
| fixnum->flonum i | bigloo procedure |  
| flonum->fixnum r | bigloo procedure |  
| elong->fixnum i | bigloo procedure |  
| fixnum->elong r | bigloo procedure |  
| llong->fixnum i | bigloo procedure |  
| fixnum->llong r | bigloo procedure |  
| elong->flonum i | bigloo procedure |  
| flonum->elong r | bigloo procedure |  
| llong->flonum i | bigloo procedure |  
For efficiency,| flonum->llong r | bigloo procedure |  string->realandstring->integerdo not
test whether the string can be read as a number.  Therefore the result
might be wrong if the string cannot be read as a number.
 These last procedures implement the natural translation
from and to fixnum, flonum, elong, and llong.
 
 
 |  
| 
| double->llong-bits z | bigloo procedure |  
Returns the double-bits as a llong.| float->int-bits z | bigloo-procedure |  |  
| 
| llong-bits->double llong | bigloo procedure |  
Converts the given llong bits to a double.| int-bits->float int | bigloo procedure |  |  
See r5rs, Numerical operations , for more details. 
Bigloo knows one more named characters  #\tab,  #\return, and
 #\null in addition to the  #\space and  #\newline of R5RS. A new alternate syntax exists for characters:
 #a<ascii-code>
where  <ascii-code> is the three digit decimal ASCII number
of the character to be read. Thus, for instance, the character  #\space
can be written  #a032. 
| 
| char=? char1 char2 | procedure |  
| char<? char1 char2 | procedure |  
| char>? char1 char2 | procedure |  
| char<=? char1 char2 | procedure |  
| char>=? char1 char2 | procedure |  
| char-ci=? char1 char2 | library procedure |  
| char-ci<? char1 char2 | library procedure |  
| char-ci>? char1 char2 | library procedure |  
| char-ci<=? char1 char2 | library procedure |  
| char-ci>=? char1 char2 | library procedure |  |  
| 
| char-alphabetic? char | library procedure |  
| char-numeric? char | library procedure |  
| char-whitespace? char | library procedure |  
| char-upper-case? char | library procedure |  
| char-lower-case? char | library procedure |  |  
| 
| char->integer char | procedure |  |  
| 
| char-upcase char | library procedure |  
| char-downcase char | library procedure |  |  
UCS-2 Characters are two byte encoded characters. They can be read with
the syntax:
 #u<unicode>
where  <unicode> is the four digit hexadecimal Unicode value
of the character to be read. Thus, for instance, the character  #\space
can be written  #u0020. 
| 
| ucs2? obj | bigloo procedure |  |  
| 
| ucs2=? ucs2a ucs2b | bigloo procedure |  
| ucs2<? ucs2a ucs2b | bigloo procedure |  
| ucs2>? ucs2a ucs2b | bigloo procedure |  
| ucs2<=? ucs2a ucs2b | bigloo procedure |  
| ucs2>=? ucs2a ucs2b | bigloo procedure |  
| ucs2-ci=? ucs2a ucs2b | bigloo procedure |  
| ucs2-ci<? ucs2a ucs2b | bigloo procedure |  
| ucs2-ci>? ucs2a ucs2b | bigloo procedure |  
| ucs2-ci<=? ucs2a ucs2b | bigloo procedure |  
| ucs2-ci>=? ucs2a ucs2b | bigloo procedure |  |  
| 
| ucs2-alphabetic? ucs2 | bigloo procedure |  
| ucs2-numeric? ucs2 | bigloo procedure |  
| ucs2-whitespace? ucs2 | bigloo procedure |  
| ucs2-upper-case? ucs2 | bigloo procedure |  
| ucs2-lower-case? ucs2 | bigloo procedure |  |  
| 
| ucs2->integer ucs2 | bigloo procedure |  
| integer->ucs2 i | bigloo procedure |  |  
| 
| ucs2->char ucs2 | bigloo procedure |  
| char->ucs2 char | bigloo procedure |  |  
| 
| ucs2-upcase ucs2 | bigloo procedure |  
| ucs2-downcase ucs2 | bigloo procedure |  |  
There are three different syntaxes for strings in Bigloo: traditional,
foreign or Unicode. The traditional syntax for strings may conform to
the Revised Report, see r5rs, Lexical structure . 
With the foreign syntax, C escape
sequences are interpreted as specified by ISO-C. In addition, Bigloo's
reader evaluate  \x?? sequence as an hexadecimal escape
character. For Unicode syntax, see Unicode (UCS-2) Strings . Only
the reader distinguishes between these three appearances of strings;
i.e., there is only one type of string at evaluation-time. The regular
expression describing the syntax for foreign string is:
 #"([^"]|\")*". Escape characters are controlled by
the parameter  bigloo-strict-r5rs-strings (see Parameters ). The library functions for string processing are:
 
| 
Is| string-null? s | SRFI-13 procedure |  san empty string? |  
| 
| make-string k char | procedure |  
| string char ... | library procedure |  |  
| 
| string-length string | procedure |  
| string-ref string k | procedure |  
| string-set! string k char | procedure |  |  
| 
This function returns| string=? string1 string2 | library procedure |  #tif thestring1andstring2are made of the same characters. It returns#fotherwise. |  
| 
This function returns| substring=? string1 string2 len | bigloo procedure |  #tifstring1andstring2have a
common prefix of sizelen.
 
 
| (substring=? "abcdef" "ab9989898" 2)
   => #t
(substring=? "abcdef" "ab9989898" 3)
   => #f
 |  |  
| 
| substring-at? string1 string2 offset [len] | bigloo procedure |  
This function returns| substring-ci-at? string1 string2 offset [len] | bigloo procedure |  #tifstring2is at positionoffsetin the stringstring1. It returns#fotherwise.
| (substring-at? "abcdefghij" "def" 3)
   => #t
(substring-at? "abcdefghij" "def" 2)
   => #f
(substring-at? "abcdefghij" "defz" 3)
   => #f
(substring-at? "abcdefghij" "defz" 3 3)
   => #t
 |  |  
| 
| string-ci=? string1 string2 | library procedure |  
| substring-ci=? string1 string2 len | bigloo procedure |  
| string<? string1 string2 | library procedure |  
| string>? string1 string2 | library procedure |  
| string<=? string1 string2 | library procedure |  
| string>=? string1 string2 | library procedure |  
| string-ci<? string1 string2 | library procedure |  
| string-ci>? string1 string2 | library procedure |  
| string-ci<=? string1 string2 | library procedure |  
| string-ci>=? string1 string2 | library procedure |  |  
| 
| string-index string charset [start 0] | bigloo procedure |  
Returns the first occurrence of a character of| string-index-right string charset [start len-1] | bigloo procedure |  char-or-setinstring. The argumentcharsetis either a character or a string.
If no character is found,string-indexreturns#f. |  
| 
| string-skip string charset [start 0] | bigloo procedure |  
| string-skip-right string charset [start len-1] | bigloo procedure |  string-skip(resp.string-skip-right) searches through
thestringfrom the left (resp. right), returning the index of
the first occurrence of a character which
 
 If no such index exists, the functions return false.is not equal to c (if c is a character);
is not in c (if c is a character set);
does not satisfy the predicate c (if c is a procedure). 
 
 The start and end parameters specify the beginning and end indices of
the search; the search includes the start index, but not the end
index. Be careful of "fencepost" considerations: when searching
right-to-left, the first index considered is end-1 whereas when
searching left-to-right, the first index considered is start. That is,
the start/end indices describe a same half-open interval [start,end).
 
 
 |  
| 
| string-contains string1 string2 [start 0] | bigloo procedure |  
Does string| string-contains-ci string1 string2 [start 0] | bigloo procedure |  string1contain stringstring2?
 Return the index in
 string1wherestring2occurs first as a 
substring, or false.
 
 string-contains-ciis the case-insensitive
variant. Case-insensitive comparison is done by case-folding
characters with the operation:
 
 
| (char-downcase (char-upcase c))
 |  |  
| 
| string-compare3 string1 string2 | bigloo procedure |  
This function compares| string-compare3-ci string1 string2 | bigloo procedure |  string1andstring2. It returns
a negative integer ifstring1<string2. It returns
zero if thestring1equalstring2. It returns
a positive integer ifstring1>string2. |  
| 
| string-natural-compare3 string1 string2 [start1 0] [start2 0] | bigloo procedure |  
This function compares| string-natural-compare3-ci string1 string2 [start1 0] [start2 0] | bigloo procedure |  string1andstring2according to
a natural string order. It returns
a negative integer ifstring1<string2. It returns
zero if thestring1equalstring2. It returns
a positive integer ifstring1>string2.
 
 
| (string-natural-compare "foo" "foo")
   => 0
(string-natural-compare "foo0" "foo1")
   => -1
(string-natural-compare "foo1" "foo0")
   => 1
(string-natural-compare "rfc822.txt" "rfc1.txt")
   => -1
(string-natural-compare "rfc1.txt" "rfc2086.txt")
   => -1
(string-natural-compare "rfc2086.txt" "rfc1.txt")
   => 1
(string-natural-compare "rfc822.txt" "rfc2086.txt")
   => -1
(string-natural-compare "a0" "a1")
   => -1
(string-natural-compare "a1" "a1a")
   => -1
(string-natural-compare "a1a" "a1b")
   => -1
(string-natural-compare "a1b" "a2")
   => -1
(string-natural-compare "a2" "a10")
   => -1
(string-natural-compare "a10" "a20")
   => -1
(string-natural-compare "a2" "a20")
   => -1
(string-natural-compare "x2-g8" "x2-y7")
   => -1
(string-natural-compare "1.001" "1.002")
   => -1
(string-natural-compare "1.002" "1.010")
   => -1
(string-natural-compare "1.010"  "1.02")
   => 1
(string-natural-compare "1.02" "1.1")
   => -1
(string-natural-compare "1.1" "1.02")
   => 1
(string-natural-compare "1.02" "1.3")
   => -1
 |  |  
| 
| substring string start [end] | library procedure |  stringmust be a string, andstartandendmust be
exact integers satisfying:
 
 
The optional argument|   0 <= START <= END <= (string-length STRING)
 |  enddefaults to(string-length STRING).
 
 substringreturns a newly allocated string formed from the
characters ofSTRINGbeginning with indexSTART(inclusive) 
and ending with indexEND(exclusive).
 
 
| (substring "abcdef" 0 5)
   => "abcde"
(substring "abcdef" 1 5)
   => "bcde"
 |  |  
| 
| string-shrink! string end | library procedure |  stringmust be a string, andendmust be
an exact integers satisfying:
 
 
|   0 <= END <= (string-length STRING)
 |  string-shrink!returns a newly allocated string formed from the
characters ofSTRINGbeginning with index 0 (inclusive) 
and ending with indexEND(exclusive). As much as possiblestring-shrink!changes the argumentstring. That is, as much
as possible, and for the back-ends that enable it,string-shrink!operate a side effect on its argument.
 
 
| (let ((s (string #\a #\b #\c #\d #\e)))
   (set! s (string-shrink! s 3))
   s)
   => "abc"
 |  |  
| 
| string-append string ... | library procedure |  
| string->list string | library procedure |  
| list->string list | library procedure |  
| string-copy string | library procedure |  |  
| 
Stores| string-fill! string char | bigloo procedure |  charin every element of the givenstringand returns an unspecified value. |  
| 
Returns a newly allocated version of string where each upper case
letter is replaced by its lower case equivalent.| string-downcase string | bigloo procedure |  |  
| 
Returns a newly allocated version of string where each lower case
letter is replaced by its upper case equivalent.| string-upcase string | bigloo procedure |  |  
| 
Builds a newly allocated capitalized string.| string-capitalize string | bigloo procedure |  |  
| 
Physically downcases the| string-downcase! string | bigloo procedure |  stringargument. |  
| 
Physically upcases the| string-upcase! string | bigloo procedure |  stringargument. |  
| 
Physically capitalized the| string-capitalize! string | bigloo procedure |  stringargument. |  
| 
Returns a copy of| string-for-read string | bigloo procedure |  stringwith each special character
replaced by an escape sequence. |  
| 
Fill string| blit-string! string1 o1 string2 o2 len | bigloo procedure |  string2starting at positiono2withlencharacters taken out of stringstring1from
positiono1.
 
 
| (let ((s (make-string 20 #\-)))
	(blit-string! "toto" 0 s 16 4)
	s)
   => "----------------toto"
 |  |  
| 
| string-replace string char1 char2 | bigloo procedure |  
Replace all the occurrence of| string-replace! string char1 char2 | bigloo procedure |  char1bychar2instring.
The functionstring-replacereturns a newly allocated string.
The functionstring-replace!modifies its first argument. |  
| 
| string-split string | bigloo procedure |  
Parses| string-split string delimiters | bigloo procedure |  stringand returns a list of tokens ended by a character of thedelimitersstring. Ifdelimitersis omitted, it defaults to a 
string containing a space, a tabulation and a newline characters.
 
 
| (string-split "/usr/local/bin" "/") => ("usr" "local" "bin")
(string-split "once   upon a time") => ("once" "upon" "a" "time")
 |  |  
| 
| string-cut string | bigloo procedure |  
The function| string-cut string delimiters | bigloo procedure |  string-cutbehaves asstring-splitbut it 
introduces empty strings for consecutive occurrences of delimiters.
 
 
| (string-cut "/usr//local/bin" "/") => ("usr" "" "local" "bin")
(string-cut "once   upon a time") => ("once" "" "" "" "upon" "a" "time")
 |  |  
| 
Filter the string| string-delete string char/charset/pred s [start end] | SRFI-13 procedure |  string, retaining only those characters that
are not equal tochar, not present incharset, or not
satisfyingpred. This function returns a fresh string no larger
thanend-start. |  
| 
| string-prefix-length s1 s2 [start1 end1 start2 end2] | SRFI-13 procedure |  
| string-suffix-length s1 s2 [start1 end1 start2 end2] | SRFI-13 procedure |  
| string-prefix-length-ci s1 s2 [start1 end1 start2 end2] | SRFI-13 procedure |  
Return the length of the longest common prefix/suffix of the two
strings. For prefixes, this is equivalent to the "mismatch index" for
the strings (modulo the starti index offsets).| string-suffix-length-ci s1 s2 [start1 end1 start2 end2] | SRFI-13 procedure |  
 The optional start/end indices restrict the comparison to the
indicated substrings of s1 and s2.
 |  
| 
| string-prefix? s1 s2 [start1 end1 start2 end2] | SRFI-13 procedure |  
| string-suffix? s1 s2 [start1 end1 start2 end2] | SRFI-13 procedure |  
| string-prefix-ci? s1 s2 [start1 end1 start2 end2] | SRFI-13 procedure |  
Is s1 a prefix/suffix of s2?| string-suffix-ci? s1 s2 [start1 end1 start2 end2] | SRFI-13 procedure |  
 The optional start/end indices restrict the comparison to the
indicated substrings of s1 and s2.
 
 
 |  
| 
| string-hex-intern string | bigloo procedure |  
Converts an hexadecimal| string-hex-intern! string | bigloo procedure |  stringofncharacters into an actual 
string ofn/2characters.
 
 
| (string-hex-intern "4a4b4c") => "JKL"
 |  |  
| 
Converts a| string-hex-extern string [start [end]] | bigloo procedure |  stringinto a hexadecimal representation.
 
 stringmust be a string, andstartandendmust be
exact integers satisfying:
 
 
The optional argument|   0 <= START <= END <= (string-length STRING)
 |  startdefault to 0. The optional argumentenddefaults to(string-length STRING).
 
 
| (string-hex-extern "JKL") => "4a4b4c"
 |  |  | 6.1.10 Unicode (UCS-2) Strings
 | 
UCS-2 strings cannot be read by the standard reader but UTF-8 strings
can. The special syntax for UTF-8 is described by the
regular expression:
 #u"([^]|\")*". The library functions for Unicode string processing are:
 
| 
| ucs2-string? obj | bigloo procedure |  |  
| 
| make-ucs2-string k | bigloo procedure |  
| make-ucs2-string k char | bigloo procedure |  
| ucs2-string k ... | bigloo procedure |  |  
| 
| ucs2-string-length s-ucs2 | bigloo procedure |  
| ucs2-string-ref s-ucs2 k | bigloo procedure |  
| ucs2-string-set! s-ucs2 k char | bigloo procedure |  |  
| 
| ucs2-string=? s-ucs2a s-ucs2b | bigloo procedure |  
| ucs2-string-ci=? s-ucs2a s-ucs2b | bigloo procedure |  
| ucs2-string<? s-ucs2a s-ucs2b | bigloo procedure |  
| ucs2-string>? s-ucs2a s-ucs2b | bigloo procedure |  
| ucs2-string<=? s-ucs2a s-ucs2b | bigloo procedure |  
| ucs2-string>=? s-ucs2a s-ucs2b | bigloo procedure |  
| ucs2-string-ci<? s-ucs2a s-ucs2b | bigloo procedure |  
| ucs2-string-ci>? s-ucs2a s-ucs2b | bigloo procedure |  
| ucs2-string-ci<=? s-ucs2a s-ucs2b | bigloo procedure |  
| ucs2-string-ci>=? s-ucs2a s-ucs2b | bigloo procedure |  |  
| 
| subucs2-string s-ucs2 start end | bigloo procedure |  
| ucs2-string-append s-ucs2 ... | bigloo procedure |  
| ucs2-string->list s-ucs2 | bigloo procedure |  
| list->ucs2-string chars | bigloo procedure |  
| ucs2-string-copy s-ucs2 | bigloo procedure |  |  
| 
Stores| ucs2-string-fill! s-ucs2 char | bigloo procedure |  charin every element of the given s-ucs2
and returns an unspecified value. |  
| 
Builds a newly allocated ucs2-string with lower case letters.| ucs2-string-downcase s-ucs2 | bigloo procedure |  |  
| 
Builds a new allocated ucs2-string with upper case letters.| ucs2-string-upcase s-ucs2 | bigloo procedure |  |  
| 
Physically downcases the| ucs2-string-downcase! s-ucs2 | bigloo procedure |  s-ucs2argument. |  
| 
Physically upcases the| ucs2-string-upcase! s-ucs2 | bigloo procedure |  s-ucs2argument. |  
| 
| ucs2-string->utf8-string s-ucs2 | bigloo procedure |  
Convert UCS-2 strings to (or from) UTF-8 encoded ascii strings.| utf8-string->ucs2-string string | bigloo procedure |  |  
| 
Returns| utf8-string? string [strict #f] | bigloo procedure |  #tif and only if the argumentstringis a well formed
UTF-8 string. Otherwise returns#f.
 If the optional argument
 strictis#t, half utf16-surrogates are
rejected. The optional argumentstrictdefaults to#f.
 
 |  
| 
Returns| ascii-string? string | bigloo procedure |  #tif and only if the argumentstringis only composed
of ascii characters. Otherwise returns#f. |  
| 
Returns a copy of| utf8-string-encode string [strict #f] | bigloo procedure |  stringwhere all the illegal UTF-8 prefix are
replaced with the Unicode Replacement Character EF BF BD. The result
is a well formed UTF-8 string.
 
 |  
| 
Returns the number of characters of an UTF-8 string. It raises an error
if the string is not a well formed UTF-8 string (i.e., it does satisfies
the| utf8-string-length string | bigloo procedure |  utf8-string?predicate. |  
| 
Returns the number of code points of an UTF-8 string. The code points
length is the number of 16bits long values needed to encode the utf8
strings in utf16.| utf8-codepoint-length string | bigloo procedure |  |  
| 
Returns the character (represented as an UTF-8 string) at the position| utf8-string-ref string i | bigloo procedure |  iinstring. |  
| 
| utf8-substring string start [end] | library procedure |  stringmust be a string, andstartandendmust be
exact integers satisfying:
 
 
The optional argument|   0 <= START <= END <= (string-length STRING)
 |  enddefaults to(utf8-string-length STRING).
 
 utf8-substringreturns a newly allocated string formed from the
characters ofSTRINGbeginning with indexSTART(inclusive) 
and ending with indexEND(exclusive).
 If the argument
 stringis not a well formed UTF-8 string an error
is raised. Otherwise, the result is also a well formed UTF-8 string. |  
| 
| iso-latin->utf8 string | bigloo procedure |  
| iso-latin->utf8! string | bigloo procedure |  
| utf8->iso-latin string | bigloo procedure |  
| utf8->iso-latin! string | bigloo procedure |  
| utf8->iso-latin-15 string | bigloo procedure |  
Encode and decode iso-latin strings into utf8. The functions| utf8->iso-latin-15! string | bigloo procedure |  iso-latin->utf8-string!,utf8->iso-latin!andutf8->iso-latin-15!may return, as result, the string they
receive as argument. |  
| 
| cp1252->utf8 string | bigloo procedure |  
| cp1252->utf8! string | bigloo procedure |  
| utf8->cp1252 string | bigloo procedure |  
Encode and decode cp1252 strings into utf8. The functions| utf8->cp1252! string | bigloo procedure |  cp1252->utf8-string!andutf8->cp1252!may return,
as result, the string they receive as argument. |  
| 
| 8bits->utf8 string table | bigloo procedure |  
| 8bits->utf8! string table | bigloo procedure |  
| utf8->8bits string inv-table | bigloo procedure |  
These are the general conversion routines used internally by| utf8->8bits! string inv-table | bigloo procedure |  iso-latin->utf8andcp1252->utf8. They convert any 8
bitsstringinto its equivalent UTF-8 representation and vice versa.
 The argument
 tableshould be either#f, which means that
the basic (i.e., iso-latin-1) 8bits -> UTF-8 conversion is
used, or it must be a vector of at least 127 entries
containing strings of characters.  This table contains the encodings for
the 8 bits characters whose code range from 128 to 255.
 The table is not required to be complete. That is, it is not required
to give the whole character encoding set. Only the characters that
need a non-iso-latin canonical representation must be given. For instance, the
CP1252 table can be defined as:
 
 
 
The argument| (define cp1252
   '#("\xe2\x82\xac" ;; 0x80
      ""             ;; 0x81
      "\xe2\x80\x9a" ;; 0x82
      "\xc6\x92"     ;; 0x83
      "\xe2\x80\x9e" ;; 0x84
      "\xe2\x80\xa6" ;; 0x85
      "\xe2\x80\xa0" ;; 0x86
      "\xe2\x80\xa1" ;; 0x87
      "\xcb\x86"     ;; 0x88
      "\xe2\x80\xb0" ;; 0x89
      "\xc5\xa0"     ;; 0x8a
      "\xe2\x80\xb9" ;; 0x8b
      "\xc5\x92"     ;; 0x8c
      ""             ;; 0x8d
      "\xc5\xbd"     ;; 0x8e
      ""             ;; 0x8f
      ""             ;; 0x90
      "\xe2\x80\x98" ;; 0x91
      "\xe2\x80\x99" ;; 0x92
      "\xe2\x80\x9c" ;; 0x93
      "\xe2\x80\x9d" ;; 0x94
      "\xe2\x80\xa2" ;; 0x95
      "\xe2\x80\x93" ;; 0x96
      "\xe2\x80\x94" ;; 0x97
      "\xcb\x9c"     ;; 0x98
      "\xe2\x84\xa2" ;; 0x99
      "\xc5\xa1"     ;; 0x9a
      "\xe2\x80\xba" ;; 0x9b
      "\xc5\x93"     ;; 0x9c
      ""             ;; 0x9d
      "\xc5\xbe"     ;; 0x9e
      "\xc5\xb8"))   ;; 0x9f
 |  inv-tableis an inverse table that can be build from
a table and using the functioninverse-utf8-table. |  
| 
Inverse an UTF-8 table into an object suitable for| inverse-utf8-table vector | procedure |  utf8->8bitsandutf8->8bits!. |  
Vectors are not autoquoted objects. 
| 
| make-vector k obj | procedure |  
| vector obj ... | library procedure |  |  
| 
| vector-length vector | procedure |  
| vector-ref vector k | procedure |  
| vector-set! vector k obj | procedure |  |  
| 
| vector->list vector | library procedure |  
| list->vector list | library procedure |  |  
| 
Stores| vector-fill! vector obj | library procedure |  objin every element ofvector. For instance:
 
 
| (let ((v (make-vector 5 #f)))
   (vector-fill! v #t)
   v)
 |  |  
| 
Allocate a new vector of size| copy-vector vector len | bigloo procedure |  lenand fills it with the firstlenelement ofvector. The new lengthlenmay be bigger than
the old vector length. |  
| 
| vector-copy vector start end | bigloo procedure |  vectormust be a vector, andstartandendmust be
exact integers satisfying:
 
 
|   0 <= START <= END <= (vector-length VECTOR)
 |  vector-copyreturns a newly allocated vector formed from the
elements ofVECTORbeginning with indexSTART(inclusive) 
and ending with indexEND(exclusive).
 
 
| (vector-copy '#(1 2 3 4) 0 4)
   => '#(1 2 3 4)
(vector-copy '#(1 2 3 4) 1 3)
   => '#(2 3)
 |  |  
| 
Copies a block of elements from| vector-copy! target tstart source [sstart [send]] | bigloo procedure |  sourcetotarget, both of
which must be vectors, starting in target attstartand starting in
source atsstart, ending whensend - sstartelements have been
copied. It is an error fortargetto have a length less thantstart + (send - sstart).Sstartdefaults to0andsenddefaults to the length ofsource. |  
See r5rs, Vectors , for more details. 
| 
Returns a newly allocated vector that contains all elements in order
from the subsequent locations in vector ....| vector-append vector ... | bigloo procedure |  
 Examples:
 
 
 
| (vector-append '#(x) '#(y)) => #(x y)
(vector-append '#(a) '#(b c d)) => #(a b c d)
(vector-append '#(a #(b)) '#(#(c))) => #(a #(b) #(c))
 |  |  
| 
| vector-map proc vector ... | bigloo procedure |  
The function| vector-map! proc vector ... | bigloo procedure |  vector-mapcreates a new vector whose size the is
the size of its argumentvector. Each elements of the new vector
is the result of applyprocto the corresponding elements of the 
initial vectors.
 The function
 vector-map!modifies the elements of the argumentvector. |  | 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: ::s8vectorsigned exact integer in the range -(2^7) to (2^7)-1::u8vectorunsigned exact integer in the range 0 to (2^8)-1::s16vectorsigned exact integer in the range -(2^15) to (2^15)-1::u16vectorunsigned exact integer in the range 0 to (2^16)-1::s32vectorsigned exact integer in the range -(2^31) to (2^31)-1::u32vectorunsigned exact integer in the range 0 to (2^32)-1::s64vectorsigned exact integer in the range -(2^63) to (2^63)-1::u64vectorunsigned exact integer in the range 0 to (2^64)-1f32vectorinexact small realf64vectorinexact 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,32and().  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 accomomdate the many Scheme systems that use the read
procedure to parse programs.
 
the following predefined procedures are available:
| 
| 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 |  
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.| list->TAGvector TAGlist | SRFI-4 procedure |  
 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.
 |  
 
 
| 
| apply proc arg1 ... args | procedure |  |  
| 
| map proc list1 list2 ... | library procedure |  
| map! proc list1 list2 ... | bigloo procedure |  
| for-each proc list1 list2 ... | library procedure |  |  
| 
| filter pred list ... | library procedure |  
Strip out all elements of| filter! pred list ... | library procedure |  listfor which the predicatepredis not true. The second versionfilter!is destructive:
 
 
| (filter number? '(1 2 #\a "foo" foo 3)) => (1 2 3)
(let ((l (list 1 2 #\a "foo" 'foo 3)))
   (set! l (filter! number? l))
   l)                                   => (1 2 3)
 |  |  
| 
| append-map proc list1 list2 ... | library procedure |  
The expression| append-map! proc list1 list2 ... | library procedure |  
is equivalent to:|   (append-map f clist1 clist2 ...)
 |  
 
 
The expression|   (apply append (map f clist1 clist2 ...))
 |  
is equivalent to:|   (append-map! f clist1 clist2 ...)
 |  
 
 
|   (apply append! (map f clist1 clist2 ...))
 |  |  
| 
As| filter-map pred list ... | bigloo procedure |  mapbut only none#fvalues are accumulated in the resulting
list. The Bigloo implementation complies with the SRFI-1 description.
 
 
| (filter-map (lambda (x) (if (number? x) '- #f)) '(1 2 #\a "foo" foo 3)) => (- - -)
 |  |  
| 
| sort proc obj | bigloo procedure |  
Sorts| sort obj proc | bigloo procedure |  objaccording toproctest. The argumentobjcan
either be a vector or a list. In either case, a copy of the argument
is returned. For instance:
 
 
The second form (which uses| (let ((l '(("foo" 5) ("bar" 6) ("hux" 1) ("gee" 4))))
   (sort (lambda (x y) (string<? (car x) (car y))) l))
   => ((bar 6) (foo 5) (gee 4) (hux 1))
 |  objbeforeprocensures backward
compatibility with old Lisp systems, and older Bigloo versions. It is
deprecated. |  
| 
| force promise | library procedure |  |  
| 
This function is the same as the| call/cc proc | bigloo procedure |  call-with-current-continuationfunction of the R5RS, see r5rs, call-with-current-continuation,
but it is necessary to compile the module with the-call/ccoption to use it, see Section
See The Bigloo command line.
 Note: Since
 call/ccis difficult to compile efficiently, 
one might consider usingbind-exitinstead. 
For this reason, we decided to enablecall/cconly with a 
compiler option. |  
| 
This form provides an escape operator facility.| bind-exit escape body | bigloo syntax |  bind-exitevaluates thebody, which may refer to the variableescapewhich will denote an ``escape function'' of one
argument: when called, this escape function will return from
thebind-exitform with the given argument as the value of
thebind-exitform. Theescapecan only be used
while in the dynamic extent of the form. Bindings introduced bybind-exitare immutable.
 
 
| (bind-exit (exit)
 (for-each (lambda (x)
             (if (negative? x)
                 (exit x)))
           '(54 0 37 -3 245 19))
 #t)                                  => -3
 (define list-length
  (lambda (obj)
    (bind-exit (return)
     (letrec ((r (lambda (obj)
                    (cond ((null? obj) 0)
                          ((pair? obj)
                           (+ (r (cdr obj)) 1))
                          (else (return #f))))))
          (r obj)))))
 
 (list-length '(1 2 3 4))               => 4
(list-length '(a b . c))               => #f
 |  |  
| 
This form provides protections. Expression| unwind-protect expr protect | bigloo syntax |  expris
evaluated. If this evaluation requires the invocation of an
escape procedure (a procedure bounded by thebind-exitspecial form),protectis evaluated before the control
jump to the exit procedure. Ifexprdoes not raise any
exit procedure,unwind-protecthas the same behaviour as
thebeginspecial form except that the value of the form is 
always the value ofexpr.
 
 
| (define (my-open f)
   (if (file-exists? f)
       (let ((port (open-input-file f)))
          (if (input-port? port)
              (unwind-protect
                 (bar port)
                 (close-input-port port))))))
 |  |  
| 
Calls| dynamic-wind  before thunk after | procedure |  thunkwithout arguments, returning the result(s) of this call.Beforeandafterare called, also without arguments, as required
by the following rules (note that in the absence of calls to continuations
captured usingcall/ccthe three arguments are
called once each, in order).Beforeis called whenever execution
enters the dynamic extent of the call tothunkandafteris called
whenever it exits that dynamic extent.  The dynamic extent of a procedure
call is the period between when the call is initiated and when it
returns.  In Scheme, because ofcall/cc, the
dynamic extent of a call may not be a single, connected time period.
It is defined as follows:
 
 If a second call toThe dynamic extent is entered when execution of the body of the
called procedure begins.
 
The dynamic extent is also entered when execution is not within
the dynamic extent and a continuation is invoked that was captured
(using call/cc) during the dynamic extent.
 
It is exited when the called procedure returns.
 
It is also exited when execution is within the dynamic extent and
a continuation is invoked that was captured while not within the
dynamic extent.
 
 dynamic-windoccurs within the dynamic extent of the
call tothunkand then a continuation is invoked in such a way that theafters from these two invocations ofdynamic-windare both to be
called, then theafterassociated with the second (inner) call todynamic-windis called first.
 If a second call to
 dynamic-windoccurs within the dynamic extent of the
call tothunkand then a continuation is invoked in such a way that thebefores from these two invocations ofdynamic-windare both to be
called, then thebeforeassociated with the first (outer) call todynamic-windis called first.
 If invoking a continuation requires calling the
 beforefrom one call
todynamic-windand theafterfrom another, then theafteris called first.
 The effect of using a captured continuation to enter or exit the dynamic
extent of a call to
 beforeorafteris undefined.
 
 
 
| (let ((path '())
      (c #f))
  (let ((add (lambda (s)
               (set! path (cons s path)))))
    (dynamic-wind
      (lambda () (add 'connect))
      (lambda ()
        (add (call/cc
               (lambda (c0)
                 (set! c c0)
                 'talk1))))
      (lambda () (add 'disconnect)))
    (if (< (length path) 4)
        (c 'talk2)
        (reverse path))))
    
   => (connect talk1 disconnect connect talk2 disconnect)
 |  |  
| 
Returns the unspecified (noted as| unspecified | bigloo procedure |  #unspecified) object with 
no specific property. |  
| Delivers all of its arguments to its continuation.
Except for continuations created by the call-with-valuesprocedure, all continuations take exactly one value.
Values might be defined as follows:
 
 
| (define (values . things)
  (call/cc
    (lambda (cont) (apply cont things))))
 |  |  
| 
Calls its| call-with-values  producer consumer | procedure |  producerargument with no values and
a continuation that, when passed some values, calls theconsumerprocedure with those values as arguments.
The continuation for the call toconsumeris the
continuation of the call to call-with-values.
 
 
| (call-with-values (lambda () (values 4 5))
                  (lambda (a b) b))
    => 5
(call-with-values * -)
    => -1
 |  |  
| 
| multiple-value-bind (var ...) producer exp ... | bigloo syntax |  
Evaluates| receive (var ...) producer exp ... | bigloo syntax |  exp... in a environment wherevar... are bound 
from the evaluation ofproducer. The result ofproducermust 
be a call tovalueswhere the number of argument is the number of 
bound variables.
| (define (bar a)
   (values (modulo a 5) (quotient a 5)))
 (define (foo a)
   (multiple-value-bind (x y)
      (bar a)
      (print x " " y)))
 
 (foo 354)
   -| 4 70
 |  |  
This section describes Scheme operation for reading and writing data.
The section Files  describes functions for handling files.
 
| 
| call-with-input-file string proc | library procedure |  
| call-with-input-string string proc | bigloo procedure |  
| call-with-output-file string proc | library procedure |  
| call-with-append-file string proc | library procedure |  
These two procedures call| call-with-output-string proc | library procedure |  procwith one argument, a port obtained
by openingstring.
See r5rs, Ports, for more details.
 
 
| (call-with-input-file "/etc/passwd"
   (lambda (port)
      (let loop ((line (read-line port)))
         (if (not (eof-object? line))
             (begin
                (print line)
                (loop (read-line port)))))))
 |  |  
| 
| input-port? obj | procedure |  
| input-string-port? obj | procedure |  
| output-port? obj | procedure |  
| output-string-port? obj | procedure |  |  
| 
| input-port-name obj | bigloo procedure |  
| input-port-name-set! obj name | bigloo procedure |  
| output-port-name obj | bigloo procedure |  
Returns/sets the file name for which| output-port-name-set! obj name | bigloo procedure |  objhas been opened. |  
| 
Returns the source number of bytes, i.e., the number characters contains
in the source. Returns| input-port-length obj | bigloo (>=3.8d) procedure |  -1if that number is unknown (typically
for a pipe). |  
| 
| input-port-timeout-set! port time | bigloo (>=2.8b) procedure |  
These two functions limit the time an read or write operation may last.
If the| output-port-timeout-set! port time | bigloo (>=2.8b) procedure |  timelimit (expressed in microseconds) exceeded, an exception
of time&io-timeout-erroris raised.
 Setting a timeout equal to 0, restore the socket in blocking mode. Setting
a timeout with a value lesser than 0 is ignored.
 
 Note: ports created from sockets share their internal file descriptor. Hence
it is erroneous to set a timeout for only one of the two ports. Both
must be set.
 |  
| 
| output-port-flush-hook port | bigloo procedure |  
Returns (resp. sets) the flush hook of the output| output-port-flush-hook-set! port hook | bigloo procedure |  port. The flush hook is a procedure of two arguments, the output
port and the number of characters that are to be actually written out
during the flush. It is unspecified when the hook is invoked, however,
one may expect the C back-end to invoke the hook only when output
buffers are full. The other back-ends (JVM and DOTNET) are likely to
invoke the hook as soon as a character is to be written.
 A flush hook can return two types of values:
 
 
 A string, which is then directly displayed to the system stream
associated with the output port.
 
An integer, which denotes the number of characters of the output port
flush buffer (see output-port-flush-buffer) that have to be
displayed on the system stream.
 |  
| 
| output-port-flush-buffer port | bigloo procedure |  
These functions gets and sets a buffer that can be used by program by the
flush hooks. The runtime system makes no provision for automatically allocated
these buffers that hence must be manually allocated by programs. The motivation
for flush buffer is to allow programs to write flush hooks that don't have
to allocate a new string each time invoked.| output-port-flush-buffer-set! port buffer | bigloo procedure |  |  
| 
| output-port-close-hook port | bigloo procedure |  
Returns (resp. sets) the close hook of the output| output-port-close-hook-set! port proc | bigloo procedure |  port. The
close hook is a procedure of one argument, the closed port. The hook 
is invoked after theportis closed. |  
| 
| input-port-close-hook port | bigloo procedure |  
Returns (resp. sets) the close hook of the input| input-port-close-hook-set! port proc | bigloo procedure |  port. The
close hook is a procedure of one argument, the closed port.
 Example:
 
| (let ((p (open-input-string "/etc/passwd")))
  (input-port-close-hook-set! p (lambda () (display 'done)))
  ...
  (close-input-port p))
 |  |  
| 
Re-open the input port| input-port-reopen! obj | bigloo procedure |  obj. That is, re-start reading from the first
character of the input port. |  
| 
| current-input-port | procedure |  
| current-output-port | procedure |  
| current-error-port | bigloo procedure |  |  
| 
| with-input-from-file string thunk | optional procedure |  
| with-input-from-string string thunk | optional procedure |  
| with-input-from-procedure procedure thunk | optional procedure |  
| with-output-to-file string thunk | optional procedure |  
| with-append-to-file string thunk | optional procedure |  
| with-error-to-file string thunk | bigloo procedure |  
| with-output-to-string thunk | bigloo procedure |  
| with-output-to-procedure procedure thunk | bigloo procedure |  
| with-error-to-string thunk | bigloo procedure |  
A port is opened from file| with-error-to-procedure procedure thunk | bigloo procedure |  string. This port is made the
current input port (resp. the current output port or the current error port) 
andthunkis called. 
See r5rs, Ports, for more details.
 
 
| (with-input-from-file "/etc/passwd"
   (lambda ()
      (let loop ((line (read-line (current-input-port))))
         (if (not (eof-object? line))
             (begin
                (print line)
                (loop (read-line (current-input-port))))))))
 |  |  
| 
| with-input-from-port port thunk | bigloo procedure |  
| with-output-to-port port thunk | bigloo procedure |  
| with-error-to-port port thunk | bigloo procedure |  with-input-from-port,with-output-to-portandwith-error-to-portall supposeportto be a legal port. They 
callthunkmakingportthe current input (resp. output or
error) port. None of these functions closeporton the continuation 
ofthunk.
 
 
| (with-output-to-port (current-error-port) 
   (lambda () (display "hello")))
 |  |  
| 
| open-input-file file-name [buffer #f] [timeout 5000000] | procedure |  
 If
 file-nameis a regular file name,open-input-filebehaves as
the function defined in the Scheme report. Iffile-namestarts with
special prefixes it behaves differently. Here are the recognized prefixes:
 
 The optional argument| (a string made of the characters#\|and#\space)
Instead of opening a regular file, Bigloo opens an input pipe. 
The same syntax is used for output file.
 
 
| (define pin (open-input-file "| cat /etc/passwd"))
(define pout (open-output-file "| wc -l"))
 (display (read pin) pout)
(close-input-port pin)
(newline pout)
(close-output-port pout)
 | pipe:Same as| .
 
file:Opens a regular file.
 
gzip:Opens a port on a gzipped filed. This is equivalent toopen-input-gzip-file. 
Example:
 
 
| (with-input-from-file "gzip:bigloo.tar.gz"
   (lambda ()
      (send-chars (current-input-port) (current-output-port))))
 | string:Opens a port on a string. This is equivalent toopen-input-string. 
Example:
 
 
| (with-input-from-file "string:foo bar Gee"
   (lambda ()
      (print (read))
      (print (read))
      (print (read))))
   -| foo
   -| bar
   -| Gee
 | http://server/pathOpens an http connection onserverand open an input file
on filepath.
 
http://server:port-number/pathhttp://user:password@server:port-number/pathOpens an http connection onserver, on port numberportwith an authentication and open an input file on filepath.
 
ftp://server/pathftp://user:password@server/pathOpens an ftp connection onserverand open an input file
on filepath. Log in as anonymous.
 
ressource:Opens a JVM ressource file. Opening aressource:file in 
non JVM backend always return#f. On the JVM backend it returns
a input port if the ressource exists. Otherwise, it returns#f.
 
 buffercan either be:
 
 The optional argumentA positive fixnum, this gives the size of the buffer.
The boolean #t, a buffer is allocated.The boolean #f, the socket is unbufferized.A string, it is used as buffer.
 timeout, an integer represents a microseconds 
timeout for the open operation. |  
| 
| open-input-gzip-file file-name [buffer #t] | bigloo procedure |  
Open respectively a gzipped file for input and a port on a gzipped stream.
Note that closing a gzip port opened from a port| open-input-gzip-port input-port [buffer #t] | bigloo procedure |  pidoes not close
thepiport.
 
 
| (let ((p (open-input-gzip-file "bigloo.tar.gz")))
   (unwind-protect
      (read-line p1)
      (close-input-port p)))
 |  
| (let* ((p1 (open-input-file "bigloo.tar.gz"))
       (p2 (open-input-gzip-port p1)))
   (unwind-protect
      (read-line p2)
      (close-input-port p2)
      (close-input-port p1)))
 |  |  
| 
| open-input-zlib-file file-name [buffer #t] | bigloo procedure |  
Open respectively a zlib file for input and a port on a zlib stream.
Note that closing a zlib port opened from a port| open-input-zlib-port input-port [buffer #t] | bigloo procedure |  pidoes not close
thepiport. |  
| 
| open-input-string string [start 0] [end] | bigloo procedure |  
| open-input-string! string [start 0] [end] | bigloo procedure |  stringmust be a string, andstartandendmust be
exact integers satisfying:
 
 
The optional argument|   0 <= START <= END <= (string-length STRING)
 |  enddefaults to(string-length STRING).
 Returns an
 input-portable to deliver characters fromstring.
 The function
 open-input-string!acts asopen-input-stringbut it might modify the string it receives as parameter. |  
| 
Returns an| open-input-c-string string | bigloo procedure |  input-portable to deliver characters from
Cstring. The buffer used by the input port is the exact
same string as the argument. That is, no buffer is allocated. |  
| 
Returns an| open-input-ftp-file file-name [buffer #t] | bigloo procedure |  input-portable to deliver characters from a
remote file located on a FTP server.
 Example:
 
 
 
The file name may contain user authentication such as:| (let ((p (open-input-ftp-file "ftp-sop.inria.fr/ls-lR.gz'')))
  (unwind-protect
     (read-string p)
     (close-input-port p)))
 |  
 
 
| (let ((p (open-input-ftp-file "anonymous:foo@ftp-sop.inria.fr/ls-lR.gz'')))
  (unwind-protect
     (read-string p)
     (close-input-port p)))
 |  |  
| 
Returns an| open-input-procedure procedure [buffer #t] | bigloo procedure |  input-portable to deliver characters fromprocedure. Each time a character has to be read, theprocedureis called. This procedure may returns a string of characters, or
the boolean#f. This last value stands for the end of file.
 Example:
 
 
 
| (let ((p (open-input-procedure (let ((s #t))
				  (lambda ()
				     (if s
					 (begin 
                                            (set! s #f)
                                            "foobar")
					 s))))))
   (read))
 |  |  
| 
| unread-char! char [input-port] | bigloo procedure |  
| unread-string! string [input-port] | bigloo procedure |  
Pushes the given| unread-substring! string start end [input-port] | bigloo procedure |  char,stringor substring into the input-port.
The next read character(s) will be the pushed ones. Theinput-portmust
be buffered and not be closed.
 Example:
 
 
 
| (define p (open-input-string "a ymbol c"))
(read p)                       => a
(read-char p)                  => #\space
(unread-char! #\s p)
(read p)                       => symbol
(read-char p)                  => #\space
(read p)                       => c
(char-ready? p)                => #f
(unread-string! "sym1 sym2" p)
(char-ready? p)                => #t
(read p)                       => sym1
(read p)                       => sym2
 |  |  
| 
The same syntax as| open-output-file file-name | procedure |  open-input-filefor file names applies here.
When a file name starts with | , Bigloo opens an output pipe
instead of a regular file. |  
| 
If| append-output-file file-name | bigloo procedure |  file-nameexists, this function returns anoutput-porton it, without removing it. New output will be appended tofile-name.
Iffile-namedoes not exist, it is created. |  
| 
This function returns an output string port. This object has almost
the same purpose as| open-output-string | bigloo procedure |  output-port. It can be used with all
the printer functions which acceptoutput-port. An output
on a output string port memorizes all the characters written. An
invocation offlush-output-portorclose-output-porton an 
output string port returns a new string which contains all the 
characters accumulated in the port. |  
| 
Given an output port created by| get-output-string output-port | bigloo procedure |  open-output-string, 
returns a string consisting of the characters that have been 
output to the port so far. |  
| 
This function returns an output procedure port. This object has almost
the same purpose as| open-output-procedure proc [flush [close]] | bigloo procedure |  output-port. It can be used with all
the printer functions which acceptoutput-port. An output
on a output procedure port invokes theprocprocedure
each time it is used for writing. That is,procis invoked with a
string denoting the displayed characters. When the functionflush-output-portis called on such a port, the optionalflushprocedure is invoked. When the functionclose-output-portis called on such a port, the optionalcloseprocedure is invoked. |  
| 
| close-input-port input-port | procedure |  
According to R5RS, the value returned is unspecified. However, if
output-port was created using| close-output-port output-port | procedure |  open-output-string, the value
returned is the string consisting of all characters sent to the port. |  
| 
| closed-input-port? input-port | procedure |  
Predicates that return| closed-output-port? output-port | procedure |  #tif and if their associated port is closed.
Return#fotherwise. |  
| 
Returns the name of the file used to open the| input-port-name input-port | bigloo procedure |  input-port. |  
| 
| input-port-position port | bigloo procedure |  
Returns the current position (a character number), in the| output-port-position port | bigloo procedure |  port. |  
| 
| set-input-port-position! port pos | bigloo procedure |  
These functions set the file position indicator for| set-output-port-position! port pos | bigloo procedure |  port. The new 
position, measured in bytes, is specified bypos. It is an error 
to seek a port that cannot be changed (for instance, a procedure or a 
console port). The result of these functions is unspecified. An error
is raised if the position cannot be changed. |  
| 
This function re-opens the input| input-port-reopen! input-port | bigloo procedure |  input-port. That is, it reset the
position in theinput-portto the first character. |  
| 
| read [input-port] | procedure |  
| read/case case [input-port] | bigloo procedure |  
| read-case-sensitive [input-port] | bigloo procedure |  
Read a lisp expression. The case sensitivity of| read-case-insensitive [input-port] | bigloo procedure |  readis unspecified. 
If have to to enforce a special behavior regarding the case, useread/case,read-case-sensitiveorread-case-insensitive. 
Let us consider the following source code: The value of theread/case'scaseargument may either beupcase,downcaseorsensitive. Using any other value is an error.
 
 
Thus:| (define (main argv)
   (let loop ((exp (read-case-sensitive)))
      (if (not (eof-object? exp))
          (begin
             (display "exp: ")
             (write exp)
             (display " [")
             (display exp)
             (display "]")
             (print " eq?: " (eq? exp 'FOO) " " (eq? exp 'foo))
             (loop (read-case-sensitive))))))
 |  
| > a.out
foo
  -| exp: foo [foo] eq?: #f #t
FOO
  -| exp: FOO [FOO] eq?: #t #f
 |  |  
| 
| read/rp grammar port | bigloo procedure |  
These functions are fully explained in Regular Parsing,
and Lalr Parsing.| read/lalrp lalrg rg port [emptyp] | bigloo procedure |  |  
| 
Note: This feature is experimental and might be removed in feature versions.| define-reader-ctor symbol procedure | bigloo procedure |  
 The present SRFI-10
(http://srfi.schemers.org/srfi-10/srfi-10.html) proposes an
extensible external representation of Scheme values, a notational
convention for future SRFIs. This SRFI adds
 #,(as a new token and
extends production rules of the grammar for a Scheme reader. The#,()form can be used for example to denote values that do not have a
convenient printed representation, as well for conditional code
compilation. It is proposed that future SRFIs that contain new read
syntax for values use the#,()notation with an appropriate tag
symbol.
 As a particular example and the reference implementation for the
 #,()convention, this SRFI describes an interpretation of the#,()external
form as a read-time application.
 Examples:
 
| (define-reader-ctor 'list list) 
(with-input-from-string "#,(list 1 2 #f \"4 5\")" read) => (1 2 #f "4 5")
 (define-reader-ctor '+ +)
(with-input-from-string "#,(+ 1 2)" read) => 3
 |  |  
| 
Note: This feature is experimental and might be removed in feature versions.| set-read-syntax! char procedure | bigloo procedure |  
 Registers a function
 procedureto be invoked with one argument, an
input-port, that is invoked when the reader hits an unparsed character.
 Example:
 
 
 
| (set-read-syntax! #\{
   (lambda (port)
      (let loop ((c (peek-char port)) (exps '()))
	 (cond ((eof-object? c)
		(error "{" "EOF encountered while parsing { ... } clause" port))
	       ((char=? c #\})
		(read-char port)   ; discard
		`(begin ,@(reverse exps)))
	       ((char-whitespace? c)
		(read-char port)   ; discard whitespace
		(loop (peek-char port) exps))
	       (else
		(let ((exp (read port)))
		   (loop (peek-char port)
                      (cons exp exps))))))))
 |  |  
| 
| read-char [port] | procedure |  
| read-byte [port] | procedure |  
| peek-char [port] | procedure |  
| peek-byte [port] | procedure |  |  
| 
As specified in the R5Rs, r5rs, Ports,| char-ready? [port] | procedure |  char-ready?returns #t if a character is ready on the inputportand
returns #f otherwise.  If char-ready returns #t then
the next read-char operation on the givenportis guaranteed
not to hang.  If theportis at end of file then char-ready?
returns #t.Portmay be omitted, in which case it defaults to
the value returned by current-input-port.
 When using
 char-ready?consider the latency that may exists
before characters are available. For instance, executing the
following source code:
 
 
Produces outputs such as:| (let* ((proc (run-process "/bin/ls" "-l" "/bin" output: pipe:))
       (port (process-output-port proc)))
   (let loop ((line (read-line port)))
      (print "char ready " (char-ready? port))
      (if (eof-object? line)
          (close-input-port port)
          (begin
             (print line)
             (loop (read-line port))))))
 |  
For a discussion of Bigloo processes, see Process.| char ready #f
total 7168
char ready #f
-rwxr-xr-x    1 root     root         2896 Sep  6  2001 arch
char ready #f
-rwxr-xr-x    1 root     root        66428 Aug 25  2001 ash
char ready #t
...
 |  
 Note: Thanks to Todd Dukes for the example and the suggestion
of including it this documentation.
 |  
| 
| read-line [input-port] | bigloo procedure |  
Reads characters from| read-line-newline [input-port] | bigloo procedure |  input-portuntil a#\Newline, 
a#\Returnor anend of filecondition is encountered.read-linereturns a newly allocated string composed of the characters 
read.
 The strings returned by
 read-linedo not contain the newline delimiters.
The strings returned byread-line-newlinedo contain them. |  
| 
Accumulates all the line of an| read-lines [input-port] | bigloo procedure |  input-portinto a list. |  
| 
Reads a sequence of non-space characters on| read-of-strings [input-port] | bigloo procedure |  input-port, makes a
string of them and returns the string. |  
| 
Reads all the characters of| read-string [input-port] | bigloo procedure |  input-portinto a string. |  
| 
| read-chars size [input-port] | bigloo procedure |  
The function| read-chars! buf size [input-port] | bigloo procedure |  read-charsreturns a newly allocated strings made
ofsizecharacters read frominput-port(or from(current-input-port)ifinput-portis not provided). If
less thansizecharacters are available on the input port, the
returned string is smaller thansize. Its size is the number of
available characters.
 The function
 read-chars!fills the bufferbufwith at mostsizecharacters. |  
| 
Fills the string| read-fill-string! s o len [input-port] | bigloo procedure |  sstarting at offsetowith at
mostlencharacters read from the input portinput-port(or from(current-input-port)ifinput-portis not provided).
This function returns the number of read characters (which may be smaller
thanlenif less characters are available) or the end of file object.
The argumentlenis a small integer.
 The function
 read-fill-string!is similar toread-chars!except that it returns the end-of-file object on termination whileread-chars!returns 0.
 Example:
 
| (let ((s (make-string 10 #\-)))
   (with-input-from-string "abcdefghijlkmnops"
      (lambda ()
         (read-fill-string! s 3 5)
         s)))
   => ---abcde--
 |  |  
| 
Returns a list of strings composed of the elements of| port->string-list input-port | bigloo procedure |  input-port. |  
| 
| port->list input-port reader | bigloo procedure |  
| port->sexp-list input-port | bigloo procedure |  Port->listapplies reader to port repeatedly until it returns EOF, 
then returns a list of results.Port->list-sexpis equivalent to(port->list read port). |  
| 
This function builds a new string out of all the characters of the file| file->string path | bigloo procedure |  path. If the file cannot be open or read, anIO_EXCEPTIONis raised. |  
| 
| send-chars input-port output-port [len] [offset] | bigloo procedure |  
Transfer the characters from| send-file filename output-port [len] [offset] | bigloo procedure |  input-porttooutput-port. This
procedure is sometimes mapped to a system call (such assendfileunder
Linux) and might thus be more efficient than copying the ports by hand. The
optional argumentoffsetspecifies an offset from which characters ofinput-portare sent. The functionsend-charsreturns the number
of characters sent.
 The function
 send-fileopens the filefilenamein order to
get its input port. On some backends,send-filemight be more efficient
thansend-charsbecause it may avoid creating a full-fledged Biglooinput-port.
 Note that the type of
 lenandoffsetiselong(i.e., exact long), which is also returned byfile-size. |  
| 
| write obj [output-port] | library procedure |  
| display obj [output-port] | library procedure |  
This procedure allows several objects to be displayed. When
all these objects have been printed,| print obj ... | bigloo procedure |  printadds a newline. |  
| 
This function is similar to| display* obj ... | bigloo procedure |  printbut does not add a newline. |  
| 
This function is the same as| fprint output-port obj ... | bigloo procedure |  printexcept that a
port is provided. |  
| 
| write-char char [output-port] | procedure |  
These procedures write a char (respec. a byte, i.e., in integer in the range
0..255) to the| write-byte byte [output-port] | procedure |  output-port. |  
| 
| newline [output-port] | procedure |  
This procedure flushes the output port| flush-output-port output-port | bigloo procedure |  output-port. This function
does not reset characters accumulated in string port. For this
uses,reset-output-port. |  
| 
| newline [output-port] | procedure |  
This function is equivalent to| reset-output-port output-port | bigloo procedure |  flush-output-portbut in addition,
for string ports, it reset the internal buffer that accumulates the
displayed characters. |  
| 
Note: Many thanks to Scott G. Miller who is the author of
SRFI-28. Most of the documentation of this function is copied from the
SRFI documentation.| format format-string [objs] | bigloo procedure |  
 Accepts a message template (a Scheme String), and processes it,
replacing any escape sequences in order with one or more characters,
the characters themselves dependent on the semantics of the escape
sequence encountered.
 
 An escape sequence is a two character sequence in the string where the
first character is a tilde
 ~. Each escape code's meaning is as
follows:
 
 ~aThe corresponding value is inserted into the string 
as if printed with display.~sThe corresponding value is inserted into the string 
as if printed with write.~%or~nA newline is inserted A newline is inserted.~~A tilde~is inserted.~rA return (#\Return) is inserted.~vThe corresponding value is inserted into the string 
as if printed with display followed by a newline. This tag is hence
equivalent to the sequence~a~n.~cThe corresponding value must be a character and is
inserted into the string as if printed with write-char.~d,~x,~o,~bThe corresponding value must
must be a number and is printed with radix 16, 8 or 2.~lIf the corresponding value is a proper list, its items 
are inserted into the string, separated by whitespaces, without the 
surrounding parenthesis. If the corresponding value is not a list, it 
behaves as~s.~(<sep>)If the corresponding value is a proper list, its items 
are inserted into the string, separated from each other bysep, 
without the surrounding parenthesis. If the corresponding value is not a list, 
it behaves as~s.~NdxobPrint a number inNcolumns with space padding.~N,<padding>dxobPrint a number innumcolumns 
withpaddingpadding.
 ~aand~s, when encountered, require a corresponding
Scheme value to be present after the format string. The values
provided as operands are used by the escape sequences in order. It is
an error if fewer values are provided than escape sequences that
require them.
 
 ~%and~~require no corresponding value.
 
 
| (format "Hello, ~a" "World!") 
   -| Hello, World!
(format "Error, list is too short: ~s~%" '(one "two" 3)) 
   -| Error, list is too short: (one "two" 3)
(format "a ~l: ~l" "list" '(1 2 3))
   -| a list: 1 2 3
(format "a ~l: ~(, )" "list" '(1 2 3))
   -| a list: 1, 2, 3
(format "~3d" 4)
   -|   4
(format "~3,-d" 4)
   -| --4
(format "~3x" 16)
   -|  10
(format "~3,0d" 5)
   -| 005
 |  |  
| 
| printf format-string [objs] | bigloo procedure |  
Formats| fprintf port format-string [objs] | bigloo procedure |  objsto the current output port or to the specifiedport. |  
| 
Pretty print| pp obj [output-port] | bigloo procedure |  objonoutput-port. |  
| Sets the variable to respect,lowerorupperto change the case for pretty-printing. |  
| 
The width of the pretty-print.| *pp-width* | bigloo variable |  |  
| 
Display recursive object| write-circle obj [output-port] | bigloo procedure |  objonoutput-port. Each component
of the object is displayed using thewritelibrary function. |  
| 
Display recursive object| display-circle obj [output-port] | bigloo procedure |  objonoutput-port. Each component
of the object is displayed using thedisplaylibrary function.
 For instance:
 
| (define l (list 1 2 3))
(set-car! (cdr l) l)
(set-car! (cddr l) l)
(display-circle l)  -| #0=(1 #0# #0#)
 |  |  
| 
| display-string string output-port | bigloo procedure |  
| display-substring string start end output-port | bigloo procedure |  Stringmust be a string, andstartandendmust be exact 
integers satisfying0 <= start <= end <= (string-length string).
 
 Display-substringdisplays a string formed from the characters
of string beginning with indexstart(inclusive) and ending with indexend(exclusive). |  
| 
Reads a password from the current input port. The reading stops when the user
hits the ,(code "Enter") key.| password [prompt] | bigloo procedure |  |  
The  mmap function asks to map a file into memory. This memory area
can be randomly accessed as a string. In general using  mmap improves
performance in comparison with equivalent code using regular ports. 
| 
Returns| mmap? obj | bigloo procedure |  #tif and only ifobjhas been produced byopen-mmap. Otherwise, it returns#f. |  
| 
Maps a file| open-mmap path [mode] | bigloo procedure |  pathinto memory. The optional argumentmodespecifies
how the file is open. The argument can be:
 
 read: #tThe memory can be readread: #fThe memory cannot be readwrite: #tThe memory can be writtenwrite: #fThe memory is read-only.
 |  
| 
Wrap a Bigloo string into a mmap object.| string->mmap string [mode] | bigloo procedure |  |  
| 
Closes the memory mapped. Returns| close-mmap mm | bigloo procedure |  #ton success,#fotherwise. |  
| 
Returns the length, an exact integer, of the memory mapped.| mmap-length mm | bigloo procedure |  |  
| 
| mmap-read-position mm | bigloo procedure |  
| mmap-read-position-set! mm offset | bigloo procedure |  
| mmap-write-position mm | bigloo procedure |  
Returns and sets the read and write position of a memory mapped memory.
The result and the argument are exact integers.| mmap-write-position-set! mm offset | bigloo procedure |  |  
| 
Reads the character in| mmap-ref mm offset | bigloo procedure |  mmatoffset, an exact long (::elong). This 
function sets the read position tooffset + 1. |  
| 
Writes the character| mmap-set! mm offset char | bigloo procedure |  charinmmatoffset, an exact
long (::elong). This function sets the write position tooffset + 1. |  
| 
Returns a newly allocated string made of the characters read from| mmap-substring mm start end | bigloo procedure |  mmstarting at positionstartand ending at positionend - 1.
If the valuesstartandendare not ranged in[0...(mmap-length mm)], an error is signaled. The functionmmap-substringsets the read position toend. |  
| 
Writes the string| mmap-substring-set! mm start str | bigloo procedure |  strtommat positionstart.
If the valuesstartandstart + (string-length str)are 
not ranged in[0...(mmap-length mm)[, an error is signaled. The functionmmap-substringsets the write position tostart + (string-length str). |  
| 
| mmap-get-char mm | bigloo procedure |  
| mmap-put-char! mm c | bigloo procedure |  
| mmap-get-string mm len | bigloo procedure |  
These functions get (resp. put) character and strings into a memory mapped
area. They increment the read (resp. write) position. An error is signaled
if the characters read (resp. writen) outbound the length of the memory mapped.| mmap-put-string! mm str | bigloo procedure |  |  
| 
| port->gzip-port input-port [buffer #t] | bigloo procedure |  
| port->zlib-port input-port [buffer #t] | bigloo procedure |  
These functions take a regular port as input (| port->inflate-port input-port [buffer #t] | bigloo procedure |  input-port). They construct
a new port that automatically unzip the read characters.
Theinflateversion does not parse a gunzip-header before inflating the
content. |  
| 
These function open a gzipped file for input. The file is automatically
unzipped when the characters are read. It is equivalent to:| open-input-inflate-file path [buffer #t] | bigloo procedure |  
 
 
The function| (let ((p (open-input-port path)))
  (port->gzip-port p))
 |  open-input-inflate-fileis similar toopen-input-gzip-filebut it does not parse a gunzip-header
before inflating the content.
 
 |  
| 
| gunzip-sendchars input-port output-port | bigloo procedure |  
Transmit all the characters from the gzipped| inflate-sendchars input-port output-port | bigloo procedure |  input-portto theoutput-port.
 Note that the function
 send-charscan also be used on gzipped
input-ports. |  
| 
Parse the header of| gunzip-parse-header input-port | bigloo procedure |  input-port. Returns#fif and only if
the port is not gzipped. |  
| 
Reads a tar header from| tar-read-header [input-port] | bigloo procedure |  input-port. If the input-port does not
conform the tar format, an IO exception is raised. On success a 
tar-header descriptor is returned. |  
| 
Reads the content of the| tar-read-block tar-header [input-port] | bigloo procedure |  tar-headerblock. |  
| 
Rounds up tar-block sizes.| tar-round-up-to-record-size int | bigloo procedure |  |  
| 
| tar-header-name tar-header | bigloo procedure |  
| tar-header-mode tar-header | bigloo procedure |  
| tar-header-uid tar-header | bigloo procedure |  
| tar-header-gid tar-header | bigloo procedure |  
| tar-header-size tar-header | bigloo procedure |  
| tar-header-mtim tar-header | bigloo procedure |  
| tar-header-checksum tar-header | bigloo procedure |  
| tar-header-type tar-header | bigloo procedure |  
| tar-header-linkname tar-header | bigloo procedure |  
| tar-header-uname tar-header | bigloo procedure |  
| tar-header-gname tar-header | bigloo procedure |  
| tar-header-devmajor tar-header | bigloo procedure |  
Return various information about| tar-header-devminir tar-header | bigloo procedure |  tar-header. |  
The following example simulates the Unix command  tar xvfz: 
| (define (untar path)
   (let ((pz (open-input-gzip-port path)))
      (unwind-protect
	 (let loop ((lst '()))
	    (let ((h (tar-read-header pz)))
	       (if (not h)
		   lst
		   (case (tar-header-type h)
		      ((dir)
		       (let ((path (tar-header-name h)))
			  (if (make-directory path)
			      (loop lst)
			      (error 'untar
				     "Cannot create directory"
				     path))))
		      ((normal)
		       (let* ((path (tar-header-name h))
			      (dir (dirname path)))
			  (when (and (file-exists? dir) (not (directory? dir)))
			     (delete-file dir))
			  (unless (file-exists? dir)
			     (make-directory dir))
			  (with-output-to-file path
			     (lambda ()
				(display (tar-read-block h pz))))
			  (loop (cons path lst))))
		      (else
		       (error 'untar
			      (format "Illegal file type `~a'"
				      (tar-header-type h))
			      (tar-header-name h)))))))
	 (close-input-port pz))))
 |  
| 
Untars the archive whose content is provided by the input port| untar input-port [:directory (pwd)] [:file #f] | bigloo procedure |  input-port.
 
 If :fileis provided,untarextract the content of the
file named:fileand returns a string. The file name must exactly
matches the files of the archive files names. If the file does not exist,untarreturns#f.
 
If :fileis not provided, it untars the whole content,
in the directory denoted by:directory, which defaults to(pwd).
The functionuntar, returns the whole list of created directories
and files.
 |  
| 
This function converts a| string->obj string #!optional extension | bigloo procedure |  stringwhich has been produced byobj->stringinto a Bigloo object.
 New in Bigloo 4.2a: The
 extensionparameter is used to decode
extension sequences.  Theses sequences of characters are
introduced by theXcharacter.  To decode an extension, the
unserializer starts decoding the item following theXas a
regular serialized item. Then, if theextensionparameter is
bound to a function, the unserializer calls that function and use the
returned value as the unserialized object. If theextensionargument is not a function, the unserializer return the ream
item.
 
 |  
| 
This function converts into a string any Bigloo| obj->string object | bigloo procedure |  objectwhich does not contain a procedure. |  
The implementation of the last two functions ensures that for every
Bigloo  object  obj (containing no procedure), the expression: 
| (equal? obj (string->obj (obj->string obj)))
   => #t
 |  
| 
| binary-port? obj | bigloo procedure |  
| open-output-binary-file file-name | bigloo procedure |  
| append-output-binary-file file-name | bigloo procedure |  
| open-input-binary-file file-name | bigloo procedure |  
| close-binary-port binary-port | bigloo procedure |  
| flush-binary-port binary-port | bigloo procedure |  
| input-obj binary-port | bigloo procedure |  
Bigloo allows Scheme objects to be dumped into, and restored from, files.
These operations are performed by the previous functions. The dump and
the restore use the two functions| output-obj binary-port obj | bigloo procedure |  obj->stringandstring->obj.
 It is also possible to use a binary file as a flat character file. This can
be done by the means of
 output-char,input-char,output-string, andinput-stringfunctions. |  
| 
| input-char binary-port | bigloo procedure |  
| output-char binary-port char | bigloo procedure |  
The function| output-byte binary-port byte | bigloo procedure |  input-charreads a single character from abinary-port. It returns the read character or theend-of-fileobject. The functionoutput-charandoutput-bytewrites a 
character, respectively a byte, into abinary-port. |  
| 
| input-string binary-port len | bigloo procedure |  
The function| output-string binary-port | bigloo procedure |  input-stringreads a string from abinary-portof
maximum lengthlen. It returns a newly allocated string whose length
is possibly smaller thanlen. The functionoutput-stringwrites 
a string into abinary-port. |  
| 
Fills a string with characters read from| input-fill-string! binary-port string | bigloo procedure |  binary-portwith at most
the length ofstring. The function returns the number of filled 
characters. |  
| 
| register-procedure-serialization! serializer unserializer | bigloo procedure |  
| register-custom-serialization! ident serializer unserializer | bigloo procedure |  
| register-process-serialization! serializer unserializer | bigloo procedure |  
There is no existing portable method to dump and restore a procedure. Thus,
if| register-opaque-serialization! serializer unserializer | bigloo procedure |  obj->stringis passed a procedure, it will emit an error message.
Sometime, using strict restrictions, it may be convenient to use an 
ad-hoc framework to serialize and unserialize procedures. User may
specify there own procedure serializer and unserializer. This is the
role ofregister-procedure-serialization!. The argumentserializeris a procedure of one argument, converting a procedure
into a characters strings. The argumentunserializeris a procedure
of one argument, converting a characters string into a procedure. It belongs
to the user to provide correct serializer and unserializer.
 Here is an example of procedure serializer and unserializer that 
may be correct under some Unix platform:
 
 
 
| (module foo
   (extern (macro %sprintf::int (::string ::string ::procedure) "sprintf")))
 (define (string->procedure str)
   (pragma "(obj_t)(strtoul(BSTRING_TO_STRING($1), 0, 16))" str))
 
 (define (procedure->string proc)
   (let ((item (make-string 10)))
      (%sprintf item "#p%lx" proc)
      item))
 
 (register-procedure-serialization! procedure->string string->procedure)
 
 (let ((x 4))
   (let ((obj (cons "toto" (lambda (y) (+ x y)))))
      (let ((nobj (string->obj (obj->string obj))))
	 (print ((cdr nobj) 5)))))
 |  |  
| 
Register a serializer/unserializer for a class. Subclasses of| register-class-serialization! class serializer unserializer | bigloo procedure |  classinherit this serializer.
 
 
| (module class-serialization-example
   (static (class point::object (x (default 10)) (y (default 20)))))
 (register-class-serialization! point
			       (lambda (o)
				  (with-access::point o (x y)
				     (cons x y)))
			       (lambda (l)
				  (instantiate::point
				     (x (car l))
				     (y (cdr l)))))
 
 (let ((o (instantiate::point)))
   (let ((s (obj->string (list o o))))
      (print (string-for-read s))
      (let ((l (string->obj s)))
	 (print l)
	 (eq? (car l) (cadr l))))) => #t
 |  |  
| 
| get-procedure-serialization | bigloo procedure |  
| get-custom-serialization ident | bigloo procedure |  
| get-process-serialization | bigloo procedure |  
| get-opaque-serialization | bigloo procedure |  
Returns the a multiple-values whose first element is the current procedure 
serializer and whose second element is the current procedure unserializer.
If no serializer/unserializer is defined, these procedures return
the values| get-class-serialization class | bigloo procedure |  #f #f. |  
These procedures allow the manipulation of fixnums as bit-fields.
 
| 
| bit-or i1 i2 | bigloo procedure |  
| bit-orelong i1 i2 | bigloo procedure |  
| bit-orllong i1 i2 | bigloo procedure |  
| bit-xor i1 i2 | bigloo procedure |  
| bit-xorelong i1 i2 | bigloo procedure |  
| bit-xorllong i1 i2 | bigloo procedure |  
| bit-and i1 i2 | bigloo procedure |  
| bit-andelong i1 i2 | bigloo procedure |  
| bit-andllong i1 i2 | bigloo procedure |  
| bit-not i | bigloo procedure |  
| bit-notelong i | bigloo procedure |  
| bit-notllong i | bigloo procedure |  
| bit-lsh i1 i2 | bigloo procedure |  
| bit-lshelong i1 i2 | bigloo procedure |  
| bit-lshllong i1 i2 | bigloo procedure |  
| bit-rsh i1 i2 | bigloo procedure |  
| bit-ursh i1 i2 | bigloo procedure |  
| bit-rshelong i1 i2 | bigloo procedure |  
| bit-rshllong i1 i2 | bigloo procedure |  
| bit-urshelong i1 i2 | bigloo procedure |  
| bit-urshllong i1 i2 | bigloo procedure |  
| (bit-or 5 3)                           => 7
(bit-orelong #e5 #e3)                  => #e7
(bit-xor 5 3)                          => 6
(bit-andllong #l5 #l3)                 => #l1
(bit-not 5)                            => -6
(bit-lsh 5 3)                          => 40
(bit-rsh 5 1)                          => 2
 |  |  
Bigloo may support weak pointers. In order to activate this support,
Bigloo must be configured with the  finalization enabled.
That is, the  configure script must be invoked with
the option  --finalization=yes. When the finalization and weak
pointers support is enabled, Bigloo defines the  cond-expand
properties  bigloo-finalizer and  bigloo-weakptr.
Then a program may test the support with expressions such as: 
| (cond-expand
  (bigloo-weakptr <something>)
  (else <something-else>))
 |  
Weak pointers are pointers to objects which can be collected by the
garbage collector if they are weakly pointed to. An object is weakly
pointed to if the only pointers to it are weak pointers. Weakly
pointed objects can be collected by the garbage collector, and all the
weak pointers to such objects will cease to point to it and point to
 #unspecified instead. 
| 
Creates a weak pointer to| make-weakptr data | bigloo procedure |  data. |  
| 
Returns| weakptr? obj | bigloo procedure |  #tifobjis a weak pointer, constructed bymake-weakptr. |  
| 
Returns the data object pointed to by| weakptr-data ptr | bigloo procedure |  ptr. If the object has been
collected, it returns#unspecified. |  
Bigloo offers hash tables with support for weak pointers. Here are described 
functions which define and use them. 
| 
| make-hashtable [bucket-len] [max-bucket-len] [eqtest] [hash] [weak-keys] [weak-data] | bigloo procedure |  
Defines an hash table for which the number of buckets is| create-hashtable [:size] [:max-bucket-len] [:eqtest] [:hash] [:weak] [:max-length] [:bucket-expansion] | bigloo procedure |  size.
The variablemax-bucket-lenspecify when the table should be
resized. If provided, these two values have to be exact integers greater or
equal to 1. Normally you could ignoresizeandmax-bucket-lenarguments and callmake-hashtablewith no argument at all. The argumenteqtestenables the specification of a comparison function. The first
argument of this function is the keys contained in the table. The second
argument is the searched key. By default
hash tables rely onhashtable-equal?, which is defined as:
 
 
The argument| (define (hashtable-equal? obj1 obj2)
   (or (eq? obj1 obj2)
       (and (string? obj1)
            (string? obj2)
            (string=? obj1 obj2))))
 |  hashspecifies an hashing function. It defaults toget-hashnumber.  The argumentsweak-keys,weak-data,
andweak-bothspecify respectively whether the hash table should
use weak pointers to store the keys and/or the data.  By default a
hash table uses strong pointers for both keys and data.  Each optional
argumentssize,max-bucket-len,eqtest,hash,weak-keys, andweak-datacan be bound to the Bigloo value#unspecifiedwhich forces its default.
 The argument
 max-lengthspecifies a maximum length (in number of
buckets) for this hashtable. It defaults to16384. If during the
execution, the hashtable tries to expand itself more thanmax-length, an exception is raised. This feature helps debugging
incorrect hashtable uses because excessive expansion is generally the
signs of an incorrect behavior. Excessive expansions, cause the
garbage collector to crash at some point. This debugging feature can
be disabled by specifying a negative max length, in which case, no check
is performed at runtime.
 The argument
 bucket-expansioncontrols howmax-bucket-lenis
expanded each time the table grows. This is a floating point number that
is a multiplicative coefficient. It defaults to1.2.
 The function
 create-hashtableis equivalent tomake-hashtablebut it uses a keyword interface. The keyword argumentweakcan either
benone,data, orkeys. |  
| 
Returns| hashtable? obj | bigloo procedure |  #tifobjis an hash table, constructed bymake-hashtable. |  
| 
Returns| hashtable-weak-keys? table | bigloo procedure |  #tiftableis a hash table with weakly pointed keys. |  
| 
Returns| hashtable-weak-data? table | bigloo procedure |  #tiftableis a hash table with weakly pointed data. |  
| 
Returns the number of entries contained in| hashtable-size table | bigloo procedure |  table.
Note that for a weak hash table the size does not guarantee the real size,
since keys and/or data can dissapear before the next call to the hash table. |  
| 
Returns the boolean| hashtable-contains? table key | bigloo procedure |  #tif it exists at least one entry whose key 
iskeyintable. If not entry is found#fis returned.
Note that for a weak hash table, the fact this procedure returns#tdoes not guarantee that the key (or its associated data) will not dissapear
before the next call to the hash table. |  
| 
Returns the entry whose key is| hashtable-get table key | bigloo procedure |  keyintable. If no entry
is found, or if the key and/or value is weakly pointed to and has dissapeard,#fis returned. |  
| 
Puts| hashtable-put! table key obj | bigloo procedure |  objintableunder the keykey. This function 
returns the object bound in the table. If there was an objectobj-oldalready in the table with the same key asobj, 
this function returnsobj-old; otherwise it returnsobj. |  
| 
Removes the object associated to| hashtable-remove! table key | bigloo procedure |  keyfromtable, 
returning#tif such object
was bound in table and#fotherwise. |  
| 
If key is already in table, the new value is calculated by| hashtable-add! table key update-fun obj init-value | bigloo procedure |  (update-fun obj current-value). Otherwise thetableis extended
by an entry linking key and(update-fun obj init-value). |  
| 
If key is already in table, the new value is calculated by| hashtable-update! table key update-fun init-value | deprecated bigloo procedure |  (update-fun current-value). Otherwise thetableis extended
by an entry linking key andinit-value. |  
| 
| hashtable->vector table | bigloo procedure |  
Returns the hash table| hashtable->list table | bigloo procedure |  table's data as a vector (respectively a list). 
If the hash table is weak, the result will consist only of the data which 
haven't dissapeared yet and whose keys haven't dissapeared either. |  
| 
Returns the list of keys used in the| hashtable-key-list table | bigloo procedure |  table.
If the hash table is weak, the result will consist only of the keys which 
haven't dissapeared yet and whose data haven't dissapeared either. |  
| 
Returns a list whose elements are the result of applying| hashtable-map table fun | bigloo procedure |  funto 
each of the keys and elements oftable(no order is specified). In 
consequence,funmust be a procedure of two arguments. The first 
one is a key and the second one, an associated object.
If the hash table is weak,funwill only be mapped on sets of key/datum
which haven't dissapeared yet. |  
| 
Applies| hashtable-for-each table fun | bigloo procedure |  funto each of the keys and elements oftable(no order is specified). In consequence,funmust be a procedure
of two arguments. The first one is a key and the second one, an
associated object.
If the hash table is weak,funwill only be called on sets of key/datum
which haven't dissapeared yet. |  
| 
Filter out elements from| hashtable-filter! table fun | bigloo procedure |  tableaccording to predicatefun.
If the hash table is weak,funwill only be called on sets of key/datum
which haven't dissapeared yet. |  
Here is an example of hash table. 
| (define *table* (make-hashtable))
 (hashtable-put! *table* "toto" "tutu")
(hashtable-put! *table* "tata" "titi")
(hashtable-put! *table* "titi" 5)
(hashtable-put! *table* "tutu" 'tutu)
(hashtable-put! *table* 'foo 'foo)
 
 (print (hashtable-get *table* "toto"))
   -| "tutu"
(print (hashtable-get *table* 'foo))
   -| 'foo
(print (hashtable-get *table* 'bar))
   -| #f
 
 (hashtable-for-each *table* (lambda (key obj) (print (cons key obj))))
   -| ("toto" . "tutu")
      ("tata" . "titi")
      ("titi" . 5)
      ("tutu" . TUTU)
      (foo . foo)
 |  
| 
This generic function computes a hash number of the instance| object-hashnumber object | bigloo generic |  object.
 Example:
 
| (define-method (object-hashnumber pt::point)
   (with-access::point pt (x y)
      (+fx (*fx x 10) y)))
 |  |  
| 
Compute a hash value for| string-hash string [start 0] [len (string-length string)] | bigloo procedure |  string, starting at indexstart, ending
at lengthlen. |  
| 6.7.1 Operating System interface
 | 
| 
| bigloo-config | bigloo procedure |  
The function| bigloo-config key | bigloo procedure |  bigloo-configreturns an alist representing the
configuration of the running Bigloo system. When used with one parameter,
the functionbigloo-configreturns the value associated with the key.
 Examples:
 
 
 
| (bigloo-config) => ((release-number . 3.4b) ... (endianess . little-endian))
(bigloo-config 'endianess) => little-endian
(bigloo-config 'int-size) => 61
 |  |  
| 
Register| register-exit-function! proc | bigloo procedure |  procas an exit functions.Procis a procedure
accepting of one argument. This argument is the numerical value which
is the status of the exit call. The registered functions are called when the 
execution ends. |  
| Apply all the registered exit functions then stops an execution, 
returning the integer int. |  
| 
Provides a signal handler for the operating system dependent signal| signal n proc | bigloo procedure |  n.procis a procedure of one argument. |  
| 
Returns the current handler associated with signal| get-signal-handler n | bigloo procedure |  nor#fif no handler is installed. |  
| 
Append all the arguments| system . strings | bigloo procedure |  stringsand invoke the native hostsystemcommand on that new string which returns an integer. |  
| 
Append all the arguments| system->string . strings | bigloo procedure |  stringsand invoke the native hostsystemcommand on that new string. If the command completes,system->stringreturns a string made of the output of the
command. |  
| 
Returns the string value of the Unix shell's| getenv [name] | bigloo procedure |  namevariable. If no
such variable is bound,getenvreturns#f. Ifnameis not provided,getenvreturns an alist composed of all 
the environment variables. |  
| 
Adds or modifies the global environment variable| putenv string val | bigloo procedure |  stringso that
it is bound tovalafter the call. This facility is not supported
by all back-end. In particular, the JVM back-end does not support it. |  
| Returns the current date in a string. See also Date. |  
| 
Sleeps for a delay during at least| sleep micros | bigloo procedure |  microsmicroseconds. |  
| 
Returns a list of strings which are the Unix command line arguments.| command-line | bigloo procedure |  |  
| 
Returns the name of the running executable.| executable-name | bigloo procedure |  |  
| Gives the OS class (e.g. unix). |  
| Gives the OS name (e.g. Linux). |  
| Gives the host architecture (e.g. i386). |  
| 
Gives the operating system version (e.g. RedHat 2.0.27).| os-version | bigloo procedure |  |  
| Gives the regular temporary directory (e.g. /tmp). |  
| 
Gives the charset used for encoding names of the file system 
(e.g. UTF-8).| os-charset | bigloo procedure |  |  
| 
Gives the operating system file separator (e.g. #\/).| file-separator | bigloo procedure |  |  
| 
Gives the operating system file path separator (e.g.#\:).| path-separator | bigloo procedure |  |  
For additional functions (such as  directory->list)
see Input and Output . 
| 
Converts a Unix path to a Bigloo list of strings.| unix-path->list | bigloo procedure |  
 
 
| (unix-path->list ".")           => (".")
(unix-path->list ".:/usr/bin")  => ("." "/usr/bin")
 |  |  
| Returns the fully qualified name of the current host. |  
| 
Evaluates the| time thunk | bigloo procedure |  thunkand returns four values: the result of callingthunk, the actual execution time, the system time, and the user time
in millisecond.
 
 
| (multiple-value-bind (res rtime stime utime)
  (time (lambda () (fib 35)))
  (print "real: " rtime " sys: " stime " user: " utime))
 |  |  
| 
| setuid uid | bigloo procedure |  
The procedure| setgid uid | bigloo procedure |  getuid(resp.getgid) returns the UID 
(resp. GID) of the user the current process is executed on behalf of.
 The procedure
 setuid(resp.setgid) set the UID 
(resp. GID) of the current process. In case of
failure, this procedure raises an error. |  
| Get the current process identifier. |  
| Get the parent process identifier. |  
| 
Maps the Posix| getgroups | bigloo procedure |  getgroupsfunction, which returns the supplementary group
IDs of the calling process. The result is a vector of IDs. On error,
an IO exception is raised. |  
| 
| getpwnam name | bigloo procedure |  
These two procedures returns information about a user. The procedure| getpwuid uid | bigloo procedure |  getpwnameaccepts a string denoting the user name as argument. The
proceduregetpwuidaccepts an UID as returned by the proceduregetuid.
 If the user is found, these two procedures returns a list of seven elements:
 
 
 When no user is found, these procedures returnsthe user name,
his encrypted password,
his uid,
his group id,
his real name,
his home directory,
his preferred shell.
 #f. |  
See Input and Output  for file and directory handling. This
section only deals with name  handling. Four procedures exist to
manipulate Unix filenames. 
| 
Returns a copy of| basename string | bigloo procedure |  stringwhere the longest prefix ending in / is
deleted if any existed. |  
| 
Returns a copy of| prefix string | bigloo procedure |  stringwhere the suffix starting by
the char #\. is deleted. If no prefix is found,
the result ofprefixis a copy ofstring. For
instance:
 
 
| (prefix "foo.scm") 
   => "foo"
(prefix "./foo.scm") 
   => "./foo"
(prefix "foo.tar.gz") 
   => "foo.tar"
 |  |  
| 
Returns a new string which is the suffix of| suffix string | bigloo procedure |  string. If no
suffix is found, this function returns an empty string. For instance,
 
 
| (suffix "foo.scm") 
   => "scm"
(suffix "./foo.scm") 
   => "scm"
(suffix "foo.tar.gz") 
   => "gz"
 |  |  
| 
Returns a new string which is the directory component of| dirname string | bigloo procedure |  string.
For instance:
 
 
| (dirname "abc/def/ghi") 
   => "abc/def"
(dirname "abc") 
   =>  "."
(dirname "abc/") 
   => "abc"
(dirname "/abc") 
   => "/"
 |  |  
| Returns the current working directory. |  
| 
Changes the current directory to| chdir dir-name | bigloo procedure |  dir-name. On success,chdirreturns#t. On failure it returns#f. |  
| 
Make an absolute file-name from a directory name| make-file-name dir-name name | bigloo procedure |  dir-nameand a relative
namename. |  
| 
Make an absolute file-name from a directory name| make-file-path dir-name name . names | bigloo procedure |  dir-nameand a relative
namenames. |  
| 
Explodes a file name into a list.| file-name->list name | bigloo procedure |  
 
 
| (file-name->list "/etc/passwd")
   => '("" "etc" "passwd")
(file-name->list "etc/passwd")
   => '("etc" "passwd")
 |  |  
| 
| file-name-canonicalize name | bigloo procedure |  
| file-name-canonicalize! name | bigloo procedure |  
| file-name-unix-canonicalize name | bigloo procedure |  
Canonicalizes a file name. If the file name is malformed this function
raises an| file-name-unix-canonicalize! name | bigloo procedure |  &io-malformed-url-errorexception.
 The function
 file-name-canonicalize!may returns its argument
if no changes in the string is needed. Otherwise, asfile-name-canonicalizeis returns a new string.
 In addition to handling
 ..directory name, the functionfile-name-unix-canonicalizealso handles the~character.
 
 
| (file-name-canonicalize "/etc/passwd")
   => "/etc/passwd"
(file-name-canonicalize "/etc/../tmp/passwd")
   => "/tmp/passwd"
(file-name-canonicalize "~/passwd")
   => "~/passwd"
(file-name-unix-canonicalize "~/passwd")
   => "/home/a-user/passwd"
(file-name-unix-canonicalize "~foo/passwd")
   => "/home/foo/passwd"
 |  |  
| 
Builds a file name relative to| relative-file-name name base | bigloo procedure |  base.
 
 
| (relative-file-name "/etc/passwd" "/etc"
   => "passwd"
 |  |  
| 
Search, in sequence, in the directory list| find-file/path name path | bigloo procedure |  pathfor the filename.  Ifnameis an absolute name, thenpathis not
used to find the file. Ifnameis a relative name, the functionmake-file-nameis used to build absolute name fromnameand
the directories inpath. The current path is not included
automatically in the list ofpath. In consequence, to check the
current directory one may add"."to thepathlist. On
success, the absolute file name is returned. On failure,#fis returned. Example:
 
 
| (find-file/path "/etc/passwd" '("/toto" "/titi")) 
   => "/etc/passwd"
(find-file/path "passwd" '("/toto" "/etc"))
   => "/etc/passwd"
(find-file/path "pass-wd" '("." "/etc"))
   => #f
 |  |  
| 
Make a static library name from| make-static-library-name name | bigloo procedure |  nameby adding the static library regular suffix. |  
| 
Make a shared library name from| make-shared-library-name name | bigloo procedure |  nameby adding the shared library regular suffix. |  
| 
This procedure returns| file-exists? string | bigloo procedure |  #tif the file (respectively directory, and link)stringexists. Otherwise it returns#f. |  
| 
This procedure returns| file-gzip? string | bigloo procedure |  #tif and only if the filestringexists
and can be unzip by Bigloo. Otherwise it returns#f. |  
| 
Deletes the file named| delete-file string | bigloo procedure |  string. The result of this procedure
is#tis the operation succeeded. The result is#fotherwise. |  
| 
Renames the file| rename-file string1 string2 | bigloo procedure |  string1asstring2. The two files have to
be located on the same file system. If the renaming succeeds, the result
is#t, otherwise it is#f. |  
| 
Truncates shall cause the regular file named by  path  to
have a size which shall be equal to length bytes.| truncate-file path size | bigloo procedure |  
 Returns
 #ton success. Returns#fotherwise. |  
| 
Copies the file| copy-file string1 string2 | bigloo procedure |  string1intostring2. If the copy succeeds, 
the result is#t, otherwise it is#f. |  
| 
This procedure returns| directory? string | bigloo procedure |  #tif the filestringexists and is a
directory. Otherwise it returns#f. |  
| 
Creates a new directory named| make-directory string | bigloo procedure |  string. It returns#tif the
directory was created. It returns#fotherwise. |  
| 
Creates a new directory named| make-directories string | bigloo procedure |  string, including any necessary
but nonexistent parent directories. It returns#tif the
directory was created. It returns#fotherwise. Note that 
if this operation fails it may have succeeded in creating some 
of the necessary parent directories. |  
| 
Deletes the directory named| delete-directory string | bigloo procedure |  string. The directory must be empty
in order to be deleted. The result of this procedure is unspecified. |  
| 
| directory->list string | bigloo procedure |  
If file| directory->path-list string | bigloo procedure |  stringexists and is a directory, the functiondirectory->listreturns the list of files instring.
The functiondirectory->path-listreturns a list of files
whose dirname isstring. |  
| 
| file-modification-time string | bigloo procedure |  
| file-access-time string | bigloo procedure |  
The date (in second) of the last modification (respec. access) for
file| file-times-set! string atime mtime | bigloo procedure |  string. The number of seconds is represented by a value
that may be converted into a date by the means ofseconds->date(see Date). |  
| 
Returns the size (in bytes) for file| file-size string | bigloo procedure |  string. The return type islong. If an full-sized integer is needed, one may write:
 
 
| (let ((sz::llong (file-size <PATH>)))
 ...)
 On error,
 -1is returned. |  |  
| 
| file-uid string | bigloo procedure |  
The functions return the user id (an integer) and group id (an integer) 
for file| file-gid string | bigloo procedure |  string. On error,-1is returned. |  
| 
Returns the file access mode (an integer). On error| file-mode string | bigloo procedure |  -1is returned. |  
| 
Returns the file type (a symbol). The possible returned values are:| file-type string | bigloo procedure |  
 
 regulardirectorylinkblockfifocharactersocketresourceunknowndoes-not-exist
 |  
| 
Change the access mode of the file named| chmod string [option] | bigloo procedure |  string. Theoptionmust be either a list of the following symbolsread,writeandexecuteor an integer. If the operation succeeds,chmodreturns#t. It returns#fotherwise. The argumentoptioncan also be an integer that represents the native file
permission.
Example:
 
 
| (chmod (make-file-name (getenv "HOME") ".bigloorc") 'read 'write)
(chmod (make-file-name (getenv "HOME") ".bigloorc") #o777)
 |  |  
Bigloo provides access to Unix-like processes as first class
objects. The implementation and this documentation are to a great
extent copies of the STk [Gallesio95] process
support. Basically, a process contains four informations: the standard
Unix process identification (aka PID) and the three standard files of
the process. 
| 
| run-process command arg... | bigloo procedure |  run-processcreates a new process and run the executable specified 
incommand. Theargcorrespond to the command line arguments. 
When is process completes its execution, non pipe associated ports are
automatically closed. Pipe associated ports have to be explicitly closed
by the program. The following values ofphave a special meaning:The following example launches a process which execute the Unix commandinput:permits to redirect the standard input file of the process.
Redirection can come from a file or from a pipe. To redirect the standard
input from a file, the name of this file must be specified afterinput:.
Use the special keywordpipe:to redirect the standard input 
from a pipe.
 
output:permits to redirect the standard output file of the
process.  Redirection can go to a file or to a pipe. To redirect the
standard output to a file, the name of this file must be specified
afteroutput:. Use the special keywordpipe:to redirect the
standard output to a pipe.
 
error:permits to redirect the standard error file of the
process.  Redirection can go to a file or to a pipe. To redirect the
standard error to a file, the name of this file must be specified
aftererror:. Use the special keywordpipe:to redirect the
standard error to a pipe.
 
wait:must be followed by a boolean value. This value
specifies if the process must be ran asynchronously or not. By
default, the process is run asynchronously (i.e.wait:if#f).
 
host:must be followed by a string. This string represents the
name of the machine on which thecommandmust be executed. This
option uses the external commandrsh. The shell variablePATHmust be correctly set for accessing it without specifying its absolute
path.
 
fork:must be followed by a boolean value. This value
specifies if the process must substitute the current execution. That is,
if the value is#ta new process is spawned otherwise, the current
execution is stopped and replaced by the execution ofcommand. It
defaults to#t.
 
env:must be followed by a string of
the form. This will bound an environment variable
in the spawned process. Avar=valrun-processcommand may contain severalenv:arguments. The current variables of the current process are
also passed to the new process.
 lswith the arguments-land/bin. The lines printed by this command
are stored in the filetmp/X.
 
 
The same example with a pipe for output:| (run-process "ls" "-l" "/bin" output: "/tmp/X")
 |  
 
 
One should note that the same program can be written with explicit 
process handling but making use of the| (let* ((proc (run-process "ls" "-l" "/bin" output: pipe:))
       (port (process-output-port proc)))
   (let loop ((line (read-line port)))
      (if (eof-object? line)
          (close-input-port port)
          (begin
             (print line)
             (loop (read-line port))))))
 |  |notation foropen-input-file.
 
 
Both input and output ports can be piped:| (let ((port (open-input-file "| ls -l /bin")))
   (let loop ((line (read-line port)))
      (if (eof-object? line)
          (close-input-port port)
          (begin
             (print line)
             (loop (read-line port))))))
 |  
 
 
Note: The call to| (let* ((proc (run-process "/usr/bin/dc" output: pipe: input: pipe:)) 
       (inport (process-input-port proc))
       (port (process-output-port proc)))
   (fprint inport "16 o")
   (fprint inport "16 i")
   (fprint inport "10")
   (fprint inport "10")
   (fprint inport "+ p")
   (flush-output-port inport)
   (let loop ((line (read-line port)))
      (if (eof-object? line)
	  (close-input-port port)
	  (begin
	     (print line)
	     (loop (read-line port))))))   -| 20
 |  flush-output-portis mandatory in order
to get thedcprocess to get its input characters.
 Note: Thanks to Todd Dukes for the example and the suggestion
of including it this documentation.
 |  
| 
Returns| process? obj | bigloo procedure |  #tifobjis a process, otherwise returns#f. |  
| 
Returns| process-alive? process | bigloo procedure |  #tifprocessis currently running, otherwise 
returns#f. |  
| 
Close the three ports associated with a process. In general the ports should
not be closed before the process is terminated.| close-process-ports command arg... | bigloo procedure |  |  
| 
Returns an integer value which represents the Unix identification (PID) of
the| process-pid process | bigloo procedure |  process. |  
| 
| process-input-port process | bigloo procedure |  
| process-output-port process | bigloo procedure |  
Return the file port associated to the standard input, output and
error of| process-error-port process | bigloo procedure |  processotherwise returns#f. 
Note that the returned port is opened for reading when callingprocess-output-portorprocess-error-port.
It is opened for writing when callingprocess-input-port. |  
| 
This function stops the current process until| process-wait process | bigloo procedure |  processcompletion.
This function returns#fwhenprocessis already terminated. It
returns#totherwise. |  
| 
This function returns the exit status of| process-exit-status process | bigloo procedure |  processif it is has
finished its execution. It returns#fotherwise. |  
| 
Sends the signal whose integer value is| process-send-signal process s | bigloo procedure |  stoprocess. Value
ofsis system dependent. The result ofprocess-send-signalis undefined. |  
| 
This function brutally kills| process-kill process | bigloo procedure |  process. The result ofprocess-killis undefined. |  
| 
| process-stop process | bigloo procedure |  
Those procedures are only available on systems that support job control. 
The function| process-continue process | bigloo procedure |  process-stopstops the execution ofprocessandprocess-continueresumes its execution. |  
| 
This function returns the list of processes which are currently running
(i.e. alive).| process-list | bigloo procedure |  |  
Bigloo defines sockets, on systems that support them, as first class objects.
Sockets permits processes to communicate even if they are on different 
machines. Sockets are useful for creating client-server applications.
The implementation and this documentation are, to a great
extent copies of the STk [Gallesio95] socket support. Bigloo supports both "stream-oriented" sockets and "datagram"
sockets (see info-file ` libc', The GNU C Library Reference Manual).  Stream-oriented sockets are
created and manipulated with the following procedures. 
| 
| make-client-socket hostname port-number #!key (timeout 0) (inbuf #t) (outbuf #t) (domain 'inet) | bigloo procedure |  make-client-socketreturns a new socket object. This socket establishes
a link between the running application listening on portport-numberofhostname. If keyword argumentsinbufandoutbufdescribe
the buffer to be used. Each can either be:
 
 Unbuffered sockets are useful for socket clients connected to servers
that do not emit #\Newline character after emissions. If the optional
argumentA positive fixnum, this gives the size of the buffer.
The boolean #t, a buffer is allocated by the Bigloo runtime system
      with a default size.The boolean #f, the socket is unbufferized.A string, it is used as buffer.
 timeoutis missing or is0, the execution blocks
until the connection is established. If thetimeoutis provided,
the execution unblocks aftertimeoutmicroseconds unless the
connection is established.
 The
 domainargument specifies the protocol used by the socket.
The supported domains are:
 
 If the connection cannot be established, aninet: IPv4 Internet protocols.unix: Unix sockets for local inter-process communications.local: Same asunix.
 &io-erroris raised
(see Errors Assertions and Traces).
 When a socket is used in unbufferized mode the characters available on
the input port must be read exclusively with
 read-charorread-line. It is forbidden to usereador any regular
grammar.  This limitation is imposed by Rgc (see Regular Parsing) that
intrinsicly associates buffers with regular grammars. If the current Rgc
implementation is improved on the coming version this restriction will
be eliminated.
 Example:
 
| ;; open a client socket on port 80:
(make-client-socket "www.inria.fr" 80) 
;; open an unbufferized connection
(make-client-socket "www.inria.fr" 80 :inbuf #f :outbuf #f)
 |  |  
| 
| socket? obj | bigloo procedure |  
| socket-server? obj | bigloo procedure |  
Returns| socket-client? obj | bigloo procedure |  #tifobjis a socket, a socket server a socket client.
Otherwise returns#f. Socket servers and socket clients are
sockets. |  
| 
Returns a string which contains the name of the distant host attached to| socket-hostname socket | bigloo procedure |  socket. Ifsockethas been created withmake-client-socketthis procedure returns the official name of the distant machine used for 
connection. Ifsockethas been created withmake-server-socket,
this function returns the official name of the client connected to the socket. 
If no client has used yet the socket, this function returns#f. |  
| 
Returns a string which contains the IP number of
the distant host attached to| socket-host-address socket | bigloo procedure |  socket. Ifsockethas been
created withmake-client-socketthis procedure returns the
IP number of the distant machine used for connection. Ifsockethas been created withmake-server-socket, this
function returns the address of the client connected to the
socket.  If no client has used yet the socket, this function returns#f. |  
| 
Returns a string which contains the IP number of
the local host attached to| socket-local-address socket | bigloo procedure |  socket. |  
| 
Returns the integer number of the port used for| socket-port-number socket | bigloo procedure |  socket. |  
| 
| socket-input socket | bigloo procedure |  
Returns the file port associated for reading or writing with the program 
connected with| socket-output socket | bigloo procedure |  socket. If no connection has already been established,
these functions return#f.
 The following example shows how to make a client socket. Here we create a
socket on port 13 of the machine ``
 kaolin.unice.fr''1:
| (let ((s (make-client-socket "kaolin.unice.fr" 13)))
  (print "Time is: " (read-line (socket-input s)))
  (socket-shutdown  s))
 |  |  
| 
| make-server-socket #!optional (port 0) #!key (name #f) (backlog 5) | bigloo procedure |  make-server-socketreturns a new socket object. 
The socket will be listening on the network interfacename, 
either on the specifiedport, or on a port chosen by the system
(usually the first port available on the network interface). Thenamecan be an IP number as a string, or a host name, whose first IP address will
be used (as returned by the name server lookup).
 The
 backlogargument specifies the size of the wait-queue used for
accepting connections. |  
| 
| socket-accept socket #!key (errp #t) (inbuf #t) (outbuf #t) | bigloo procedure |  socket-acceptwaits for a client connection on the givensocket. It returns aclient-socket.  If no client is
already waiting for a connection, this procedure blocks its caller;
otherwise, the first connection request on the queue of pending
connections is connected tosocket. This procedure must be
called on a server socket created withmake-server-socket.
 The arguments
 inbufandoutbufare similar to the ones
used bymake-client-socket. That is, each can either be:
 
 The keyword argumentA positive fixnum, this gives the size of the buffer.
The boolean #t, a buffer is allocated.The boolean #f, the socket is unbufferized.A string, it is used as buffer.
 errpis a boolean. The value#tmeans that if an error is raised it is signaled. Otherwise, it is
omitted.
 Note: When a socket is used in unbufferized mode the characters
available on the input port must be read exclusively with
 read-charorread-line. It is forbidden to usereador any regular grammar.  This limitation is imposed by Rgc (see
Regular Parsing) that intrinsicly associate buffers with regular
grammars. If the current Rgc implementation is improved on the coming
version this restriction will be suppressed.
 The following exemple is a simple server which waits for a connection
on the port 12342. Once the connection with the
distant program is established, we read a line on the input port
associated to the socket and we write the length of this line on its
output port.
 
| (let* ((s (make-server-socket 1234))
       (s2 (socket-accept s)))
  (let ((l (read-line (socket-input s2))))
    (fprint (socket-output s2) "Length is: " (string-length l))
    (flush-output-port (socket-output s2)))
  (socket-close s2)
  (socket-shutdown s))
 |  |  
| 
The function| socket-close socket | bigloo procedure |  socket-closecloses the connection established with
asocket-client. |  
| 
| socket-shutdown socket #!optional (how #t) | bigloo procedure |  Socket-shutdownshutdowns the connection associated tosocket.
 
 Closeis either a boolean or one of the symbolsRDWR,RD, orWR. The meaning of the optional how (which defaults to#t)
is as follows:
 
 The function#t, the socket is shutdown for reading and writing
and the socket is closed.#f, the socket is shutdown for reading and writing.RDWR, the socket is shutdown for reading and writing.RD, the socket is shutdown for reading.WD, the socket is shutdown for writing.
 socket-shutdownreturns an integer which is0is the operation has succeeded and a positive integer otherwise. |  
| 
Returns| socket-down? socket | bigloo procedure |  #tifsockethas been previously closed 
withsocket-shutdown. It returns#fotherwise. |  
Here is another example of making use of stream sockets: 
| (define s1 (make-server-socket))
(define s2 #unspecified)
 (dynamic-wind 
   ;; Init: Launch an xterm with telnet running
   ;; on the s listening port and connect
   (lambda ()
      (run-process "/usr/X11R6/bin/xterm" "-display" ":0" "-e" "telnet" "localhost" 
		   (number->string (socket-port-number s1)))
      (set! s2 (socket-accept s1))
      (display #"\nWelcome on the socket REPL.\n\n> " (socket-output s2))
      (flush-output-port (socket-output s2)))
 
 ;; Action: A toplevel like loop
   (lambda ()
      (let loop ()
	 (let ((obj (eval (read (socket-input s2)))))
	    (fprint (socket-output s2) "; Result: " obj)
	    (display "> " (socket-output s2))
	    (flush-output-port (socket-output s2))
	    (loop))))
 
 ;; Termination: We go here when 
   ;;     -a: an error occurs 
   ;;     -b: connection is closed
   (lambda ()
      (print #"Shutdown ......\n")
      (socket-close s2)
      (socket-shutdown s1)))
 |  
Here is a second example that uses sockets. It implements
a client-server architecture and it uses unbufferized
(see  socket-accept) input ports.
 
First, here is the code of the client: 
| (module client)
 (let* ((s (make-client-socket "localhost" 8080 :outbuf #f))
       (p (socket-output s)))
   (display "string" p)
   (newline p)
   (display "abc" p)
   (flush-output-port p)
   (let loop ()
      (loop)))
 |  
Then, here is the code of the server: 
| (module server)
 (let* ((s (make-server-socket 8080))
       (s2 (socket-accept s :inbuf #f)))
   (let ((pin (socket-input s2)))
      (let loop ()
         (display (read-char pin))
         (flush-output-port (current-output-port))
         (loop))))
 |  
At, to conclude here the source code for a server waiting for multiple
consecutive connections: 
| (define (main argv)
   (let ((n (if (pair? (cdr argv))
                (string->integer (cadr argv))
                10))
	 (s (make-server-socket)))
      (print "s: " s)
      (let loop ((i 0))
         (if (<fx i n)
             (let ((s2 (socket-accept s)))
		(print "i: " i " " s2)
		(print (read-line (socket-input s2)))
		(socket-close s2)
                (loop (+fx i 1)))
	     (socket-shutdown s)))))
 |  
Bigloo also provides primitives dealing with "datagram" sockets, for
use with transports such as UDP.  These are shown below: 
| 
Return a datagram server socket bound to the loopback address on| make-datagram-server-socket port | bigloo procedure |  port, and whose address family and protocol family are those
normally used for services onport. |  
| 
Return an unbound datagram socket.  It may then be used in conjunction
with| make-datagram-unbound-socket [(domain 'inet)] | bigloo procedure |  datagram-socket-sendanddatagram-socket-receive, for
instance send to and receive from a UDP multicast address. |  
| 
Receive up to| datagram-socket-receive sock size | bigloo procedure |  sizebytes from datagram socketsock, and
return them as a string. |  
| 
Send string| datagram-socket-send sock message host port | bigloo procedure |  messageover datagram socketsocktohostandport.hostmust be a string denoting an IPv4 or IPv6
address.  On success, return the number of bytes actually sent. |  
| 
| host hostname | bigloo procedure |  
Returns the IP number of| hostinfo hostname | bigloo procedure |  hostname. Whenhostnameis not found,
theio-unknown-host-errorexception is raided 
(see Errors Assertions and Traces).
 The function
 hostinfopossibly returns more information about the
host. It returns an association list made out the information about the
host. This list might contain anameentry, anaddressesentry,
and aaliasesentry.
 Some back-ends (e.g., the C back-end) implements DNS caching. This may
dramatically improve the performance of intensive networking applications.
DNS caching can be control by the means of two parameters:
 bigloo-dns-enable-cacheandbigloo-dns-cache-validity-timeout(see Parameters). |  
| 
Returns the list of configured interfaces, their associated IP addresses, their
protocol, and, if supported by the system, the hardware address (the mac address).| get-interfaces | bigloo procedure |  |  
| 
Reads all the entries from the protocols database and returns a list
of protocol entries. Each entries consists in a list of three elements:| get-protocols | bigloo procedure |  
 
 a string denoting the protocol name,
an integer denoting the protocol number,
a list of strings denoting the protocol aliases.
 |  
| 
Returns the protocol entry found in the protocols database. The argument| get-protocol number-or-name | bigloo procedure |  number-of-nameis either an integer or a string. |  
| 
| socket-option socket option-name | bigloo procedure |  
These two functions get and set socket option. The
argument| socket-option-set! socket option-name val | bigloo procedure |  option-namemust be a keyword. If theoption-nameis not supported by the Bigloo runtime system, the functionsocket-optionreturns the value#unspecifiedotherwise,
it returns the option value.  If theoption-nameis not supported,
the functionsocket-option-set!returnsfalse. Otherwise
it returns a non false value.
 Here is a list of possibly supported option-name values:
 
 
 The:SO_KEEPALIVE:SO_OOBINLINE:SO_RCVBUF:SO_SNDBUF:SO_REUSEADDR:SO_TIMEOUT:SO_SNDTIMEO:SO_RCVTIMEO:TCP_CORK:TCP_QUICKACK:TCP_NODELAY
 :SO_KEEPALIVEoption can be use to implement automatic notification
of client disconnection. It requires system tuning for enabling TCP keeplive
support. On Linux additional information may be found on the 
``TCP Keepalive HOWTO'' (see http://tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/).
 
 |  
Bigloo allows access to SSL sockets, certificates and private keys, in
order to build secure encrypted and/or signed communications. 
| 
Returns a string representing the SSL library version number.| ssl-version | SSL library procedure |  |  6.7.5.1 SSL Sockets
Bigloo defines SSL sockets, on systems that support them, as first
class objects. SSL Sockets permits processes to communicate even if
they are on different machines securely via encrypted
connections. SSL Sockets are useful for creating secure client-server
applications. 
| 
Returns| ssl-socket? obj | SSL library procedure |  #tif an only if obj is a SSL socket (either client or server).
Returns#fotherwise. |  
| 
| make-ssl-client-socket hostname port-number #!key (buffer #t) (timeout 0) (protocol 'sslv23) (cert #f) (pkey #f) (CAs '()) (accepted-certs #f) | SSL library procedure |  make-ssl-client-socketreturns a new client socket object. This
object satisfies thesocket?predicate (see Socket)
can be used in any context where a socket created bymake-client-socketcan be used.
 A SSL client socket establishes a link between the running application
(client) and a remote application (server) listening on port
 port-numberofhostname. If optional argumentbufsizis lesser or equal to1then the input port associated with the socket is
unbuffered. This is useful for socket clients connected to servers
that do not emit #\Newline character after emissions. The optional
argumentbuffercan either be:
 
 If the optional argumentA positive fixnum, this gives the size of the buffer.
The boolean #t, a buffer is allocated.The boolean #f, the socket is unbufferized.A string, it is used as buffer.
 timeoutis0, the execution blocks until the connection is established. If
thetimeoutis provided, the execution unblocks aftertimeoutmicroseconds unless the connection is established. If
theprotocoloption argument is given, it specifies the
encryption protocol. Accepted values are'sslv2,'sslv3,'sslv23(alias'ssl),'tls(alias'tlsv1)
or'dtls(alias'dtlsv1). The default value is'sslv23.
 The SSL socket will sign the connection using the optional arguments
 cert(for the certificate) andpkey(for the private key).
The certificatecertmust be of typecertificate, and
the private keypkeymust be of typeprivate-key.
If any of those two arguments is given, they must both be given.
If those optional arguments are missing the connection will be encrypted
but not signed from the client side.
 The
 CAsoptional argument specifies the list of certificates to
trust as CA (Certificate Authority) for the connection. It must be a 
list of values of typecertificate. If the list is empty, the
default list of trusted CA is used (set by the system). Note that
giving a list of trusted certificates turns on the peer (server)
certificate validation: an&io-errorwill be raised if the peer
(server) certificate is not signed directly or indirectly by one of the
certificates inCAs.
 The
 accepted-certsoptional argument gives a list of certificate
objects (of typecertificate) which are accepted as peer (server)
certificate. Ifaccepted-certsis#fthen every peer (server)
certificate is accepted (aside from eventual certificate validation).
Ifaccepted-certsis a list, the peer (server) certificate must
match one of the given certificates. Otherwise, an&io-errorwill be raised.
 If the connection cannot be established, an
 &io-erroris raised
(see Errors Assertions and Traces).
 When a socket is used in unbufferized mode the characters available on
the input port must be read exclusively with
 read-charorread-line. It is forbidden to usereador any regular
grammar.  This limitation is imposed by Rgc (see Regular Parsing) that
intrinsicly associates buffers with regular grammars. If the current Rgc
implementation is improved on the coming version this restriction will
be eliminated.
 The function
 make-ssl-client-socketis defined in the SSL library.
A module that needs this facility must then use alibraryclause
(see Modules). The SSL library can also be loaded from the interpreter
using thelibrary-loadfunction (see Bigloo Libraries).
 
 
| (module imap
   (library ssl)
   (main main))
 (let* ((s (make-ssl-client-socket "localhost" 993))
       (p (socket-output s)))
   (display "string" p)
   (newline p)
   (display "abc" p)
   (flush-output-port p)
   (let loop ()
      (loop)))
 |  |  
| 
Returns an SSL socket built from a socket obtained by| client-socket-use-ssl! socket #!key (protocol 'sslv23) (cert #f) (pkey #f) (CAs '()) (accepted-certs #f) | SSL library procedure |  make-client-socket(see Socket). Depending on the implementation and back-end the
returned socket may or may not beeq?tosocket. |  
| 
| make-ssl-server-socket #!key (port 0) (name #f) (protocol 'sslv23) (cert #f) (pkey #f) (CAs '()) (accepted-certs #f) | SSL library procedure |  make-ssl-server-socketreturns a new server socket object which
satisfies thesocket?predicate and which can be used in any
context where a socket created bymake-server-socketcan be
used (see Socket).
 A SSL server socket opens the port
 porton the current hostname(the server), 
and allows remote applications (clients) to connect to it.
listening on portport-numberofhostname. If the optional
argumentportis not given or is0, the server socket will
use the first availailable port number. If the optional argumentnameis given, the server socket will be bound to the network 
interface representing the given host name. If it is#f(the default)
the socket will be bound on every local network interface.
If theprotocoloption argument is
given, it specifies the encryption protocol. Accepted values are'sslv2,'sslv3,'sslv23(alias'ssl),'tls(alias'tlsv1)
or'dtls(alias'dtlsv1). The default value is'sslv23.
 The SSL socket will sign the connection using the optional arguments
 cert(for the certificate) andpkey(for the private key).
The certificatecertmust be of typecertificate, and
the private keypkeymust be of typeprivate-key.
If any of those two arguments is given, they must both be given.
If those optional arguments are missing the connection will be encrypted
but not signed from the server side, which means the peer (client) will
have to provide a certificate/private key pair to encrypt the connection,
and that seldom happens. Typical SSL servers provide their certificate
and private key.
 Note that since the peer (client) certificate is only known when we
are accepting a client socket (with
 socket-accept) theCAsandaccepted-certsoptional arguments are only checked during
the accept operation of a server socket.
 The
 CAsoptional argument specifies the list of certificates to
trust as CA (Certificate Authority) for the connection. It must be a 
list of values of typecertificate. If the list is empty, the
default list of trusted CA is used (set by the system). Note that
giving a list of trusted certificates turns on the peer (client)
certificate validation: an&io-errorwill be raised if the peer
(client) certificate is not signed directly or indirectly by one of the
certificates inCAswhen accepting the client socket.
 The
 accepted-certsoptional argument gives a list of certificate
objects (of typecertificate) which are accepted as peer (client)
certificate. Ifaccepted-certsis#fthen every peer (client)
certificate is accepted (aside from eventual certificate validation).
Ifaccepted-certsis a list, the peer (client) certificate must
match one of the given certificates. Otherwise, an&io-errorwill be raised when accepting the client socket.
 If the connection cannot be established, an
 &io-erroris raised
(see Errors Assertions and Traces).
 The function
 make-ssl-server-socketis defined in the SSL library.
A module that needs this facility must then use alibraryclause
(see Modules). The SSL library can also be loaded from the interpreter
using thelibrary-loadfunction (see Bigloo Libraries).
 
 
| (module secure-echo
   (library ssl))
 (let* ((cert (read-certificate "/etc/ssl/my_cert.crt"))
       (pkey (read-private-key "/etc/ssl/my_key.pkey"))
       (cas (read-pem-file "/etc/ssl/ca.cert"))
       (s (make-ssl-server-socket 1055 :CAs cas :cert cert :pkey pkey))
       (cs (socket-accept s))
       (ip (socket-input cs))
       (op (socket-output cs)))
   (let loop ((e (read ip)))
      (when (not (eof-object? e))
         (write e op)
         (loop (read ip))))
   (socket-close s))
 |  |  6.7.5.2 Certificates
| 
Reads an X509 certificate stored in PEM format in the given| read-certificate file | SSL library procedure |  filename.
If the file cannot be read, it raises an&io-errorcondition. Otherwise the certificate is returned. |  
| 
Reads a list of  X509 certificate stored in PEM format in the given| read-pem-file file | SSL library procedure |  filename.
If the file cannot be read, it raises an&io-errorcondition. Otherwise the list of certificate contained in
the file is returned. |  
| 
Returns| certificate? obj | SSL library procedure |  #tifobjis an SSL certificate.
Otherwise returns#f. |  
| 
Returns the CommonName (CN) part of the subject of the given certificate.| certificate-subject cert | SSL library procedure |  |  
| 
Returns the CommonName (CN) part of the issuer of the given certificate.| certificate-issuer cert | SSL library procedure |  |  6.7.5.3 Private Keys
| 
Reads a private key stored in PEM format in the given| read-private-key file | SSL library procedure |  filename.
If the file cannot be read, it raises an&io-errorcondition. Otherwise the private key is returned. |  
| 
Returns| private-key? obj | SSL library procedure |  #tifobjis an SSL private key.
Otherwise returns#f. |  
| 
Returns| date? obj | bigloo procedure |  #tif and only ifobjis a date as returned
bymake-date,current-date, orseconds->date. It
returns#fotherwise. |  
| 
Creates a| make-date #!key (nsec 0) (sec 0) (min 0) (hour 0) (day 1) (month 1) (year 1970) timezone (dst -1) | bigloo procedure |  dateobject from the integer values passed as argument.
 The argument
 timezone, if provided, is expressed in minute.
 Example:
 
The argument| (write (make-date :sec 0 :min 22 :hour 17 :day 5 :month 2 :year 2003 :dst 0))
  -| #<date:Wed Feb  5 17:22:00 2003>
 |  dstis either-1when the information is not
available,0when daylight saving is disabled,1when daylight
saving is enabled. |  
| 
Creates a new date from the argument| date-copy date #!key sec min hour day month year timezone | bigloo procedure |  date.
 Example:
 
| (date-copy (current-date) :sec 32 :min 24 :day 5)
 |  |  
| 
Returns a| current-date | bigloo procedure |  dateobject representing the current date. |  
| 
| current-seconds | bigloo procedure |  
| current-microseconds | bigloo procedure |  
Returns an| current-nanoseconds | bigloo procedure |  elonginteger representing the current epoch (i.e., the
date since 0:00:00 UTC on the morning of 1 January 1970, expressed
in seconds (resp. in micro seconds). |  
| 
| date->seconds | bigloo procedure |  
| date->nanoseconds | bigloo procedure |  
| seconds->date | bigloo procedure |  
Convert from| nanoeconds->date | bigloo procedure |  dateandelong. |  
| 
| date->string date | bigloo procedure |  
| date->utc-string date | bigloo procedure |  
| seconds->string elong | bigloo procedure |  
Construct a textual representation of the date passed in argument| seconds->utc-string elong | bigloo procedure |  |  
| 
Returns the number of seconds of a date, in the range| date-second date | bigloo procedure |  0...59. |  
| 
Returns the number of nano seconds of a date (to be added to| date-nanosecond date | bigloo procedure |  date-second). |  
| 
Returns the minute of a date, in the range| date-minute date | bigloo procedure |  0...59. |  
| 
Returns the hour of a date, in the range| date-hour date | bigloo procedure |  0...23. |  
| 
Returns the day of a date, in the range| date-day date | bigloo procedure |  1...31. |  
| 
| date-wday date | bigloo procedure |  
Returns the week day of a date, in the range| date-week-day date | bigloo procedure |  1...7. |  
| 
| date-yday date | bigloo procedure |  
Returns the year day of a date, in the range| date-year-day date | bigloo procedure |  1...366. |  
| 
Returns the month of a date, in the range| date-month date | bigloo procedure |  1...12. |  
| 
Returns the year of a date.| date-year date | bigloo procedure |  |  
| 
Returns the timezone (in seconds) of a date.| date-timezone date | bigloo procedure |  |  
| 
Returns| date-is-dst date | bigloo procedure |  -1if the information is not available,0is the
date does not contain daylight saving adjustment,1if it
contains a daylight saving adjustment. |  
| 
Converts a Bigloo fixnum integer into a second number.| integer->second | bigloo procedure |  |  
| 
Returns the number of seconds contained in one day.| day-seconds | bigloo procedure |  |  
| 
| day-name int | bigloo procedure |  
Return the name and the abbreviated name of a week day.| day-aname int | bigloo procedure |  |  
| 
| month-name int | bigloo procedure |  
Return the name and the abbreviated name of a month.| month-aname int | bigloo procedure |  |  
| 
Return the length of the month of| date-month-length date | bigloo procedure |  date. |  
| 
Returns| leap-year? int | bigloo procedure |  #tif and only if the yearintis a leap year. 
Returns#fotherwise. |  
| 
| rfc2822-date->date string | bigloo procedure |  
Parses RFC2822 string representing a date. These functions produce
a Bigloo date object.| rfc2822-parse-date input-port | bigloo procedure |  |  
| 
Converts a Bigloo date into a string representation compliant with the RFC2822
format.| date->rfc2822-date date | bigloo procedure |  |  
| 
| iso8601-date->date string | bigloo procedure |  
Parses ISO8601 string representing a date. These functions produce
a Bigloo date object.| iso8601-parse-date input-port | bigloo procedure |  |  
| 
| base64-encode string [padding 64] | bigloo procedure |  
Encodes (respec. decodes) a string into a base64 representation.| base64-decode string [no-eof-padding] | bigloo procedure |  
 When decoding, if the optional parameter
 no-eof-paddingis#t, the decoding success even if the input stream is not padded
with=characters. |  
| 
| base64-encode-port input-port output-port [padding 64] | bigloo procedure |  
Encodes (respec. decodes) an input port into a base64 representation.| base64-decode-port input-port output-port [no-eof-padding] | bigloo procedure |  
 When decode succeeds,
 base64-decode-portreturns#t, it
returns#fotherwise.
 When decoding, if the optional parameter
 no-eof-paddingis#t, the decoding success even if the input stream is not padded
with=characters. |  
| 
| pem-read-file file-name | bigloo procedure |  
Reads a PEM (Privacy Enhanced Mail) base64 encoded file.| pem-decode-port input-port output-port | bigloo procedure |  |  
| 
| md5sum obj | bigloo procedure |  
| md5sum-string string | bigloo procedure |  
| md5sum-mmap mmap | bigloo procedure |  
| md5sum-file string | bigloo procedure |  
Computes MD5 message digest.| md5sum-port input-port | bigloo procedure |  
 The function
 md5sumdispatches over its argument and invokes the
ad-hoc function. That is, it invokesmd5sum-stringif its 
argument is a string,md5sum-mmapif it is a mmap,md5sum-portif its argument is an input port. |  
| 
Computes the Hmac MD5 authentication:| hmac-md5sum-string key string | bigloo procedure |  
 
 
| (hmac-md5sum-string (make-string 16 #a011) "Hi There") 
  => "9294727a3638bb1c13f48ef8158bfc9d"
 |  |  
| 
Challenge-Response Authentication Mechanism as specified in RFC 2195.| cram-md5sum-string user key string | bigloo procedure |  
 The function
 cram-md5sum-stringassumes that data is base64 encoded.
The result is also base64 encoded. |  
| 
| sha1sum obj | bigloo procedure |  
| sha1sum-string string | bigloo procedure |  
| sha1sum-mmap mmap | bigloo procedure |  
| sha1sum-file string | bigloo procedure |  
Computes SHA1 message digest.| sha1sum-port input-port | bigloo procedure |  
 The function
 sha1sumdispatches over its argument and invokes the
ad-hoc function. That is, it invokessha1sum-stringif its 
argument is a string,sha1sum-mmapif it is a mmap,sha1sum-portif its argument is an input port. |  
| 
Computes the Hmac SHA1 authentication:| hmac-sha1sum-string key string | bigloo procedure |  |  
| 
| sha256sum obj | bigloo procedure |  
| sha256sum-string string | bigloo procedure |  
| sha256sum-mmap mmap | bigloo procedure |  
| sha256sum-file string | bigloo procedure |  
Computes SHA256 message digest.| sha256sum-port input-port | bigloo procedure |  
 The function
 sha256sumdispatches over its argument and invokes the
ad-hoc function. That is, it invokessha256sum-stringif its 
argument is a string,sha256sum-mmapif it is a mmap,sha256sum-portif its argument is an input port. |  
| 
Computes the Hmac SHA256 authentication:| hmac-sha256sum-string key string | bigloo procedure |  |  | 6.10 Cyclic Redundancy Check (CRC)
 | 
Bigloo provides several known cyclic redundancy checks as well as means to create custom
checks. Usually CRCs are executed starting with the leftmost bit inside a byte (big endian). However,
especially for serial-port transmissions, a scheme where the least-significant bit is
processed first is desirable. Bigloo's CRC procedures accept a key-parameter
( :big-endian) (by default  #t) which allows to change this behavior. The following CRCs (given with the associated polynomial) are provided:
 itu-4: 0x3epc-5: 0x9itu-5: 0x15usb-5: 0x5itu-6: 0x37: 0x9atm-8: 0x7ccitt-8: 0x8ddallas/maxim-8: 0x318: 0xd5sae-j1850-8: 0x1d10: 0x23311: 0x38512: 0x80fcan-15: 0x4599ccitt-16: 0x1021dnp-16: 0x3d65ibm-16: 0x800524: 0x5d6dcbradix-64-24: 0x864cfb30: 0x2030b9cfieee-32: 0x4c11db7c-32: 0x1edc6f41k-32: 0x741b8cd7q-32: 0x814141abiso-64: 0x1becma-182-64: 0x42f0e1eba9ea3693
 
| 
Returns a list of all provided CRCs (| crc-names | bigloo procedure |  itu-4,epc-5, etc.). |  
| 
| crc-polynomial name | bigloo procedure |  
Returns the polynomial for the given name. The| crc-polynomial-le name | bigloo procedure |  -levariant returns the
little endian polynomial.
 
 
| (crc-polynomial 'ieee-32)
    -| #e79764439 ;; == #ex4c11bd7
(crc-polynomial 24)
    -| 6122955    ;; == #x5d6dcb
 |  |  
| 
Returns the length of the specified CRC.| crc-length name | bigloo procedure |  |  
| 
| crc name obj [:init 0] [:final-xor 0] [:big-endian? #t] | bigloo procedure |  
| crc-string name str::bstring [:init 0] [:final-xor 0] [:big-endian? #t] | bigloo procedure |  
| crc-port name p::input-port [:init 0] [:final-xor 0] [:big-endian? #t] | bigloo procedure |  
| crc-mmap name m::mmap [init 0] [:final-xor 0] [big-endian? #t] | bigloo procedure |  
Computes the CRC of the given object.| crc-file name f::bstring [init 0] [:final-xor 0] [big-endian? #t] | bigloo procedure |  namemust be one of the
provided CRC-algorithms. The optional parameterinitcan be used to
initialize the CRC. The result of the CRC will be XORed withfinal-xor. The result
will however be of the CRC's length. That is, even iffinal-xoris bigger then
the CRC's length only the relevant bits will be used to perform the final XOR.
 The result will be a number. Depending on the CRC this number can be a fixnum,
an elong, or an llong.
 
 The following example mimicks the UNIX
 cksumcommand:
In the following example we implement OpenPGP's CRC-24:| (module cksum (main main))
(define (main args)
  (let loop ((sum (crc-file 'ieee-32 (cadr args)))
             (size (elong->fixnum (file-size (cadr args)))))
    (if (=fx size 0)
        (printf "~a ~a ~a\n"
                (bit-andllong #lxFFFFFFFF (elong->llong (bit-notelong sum)))
                (file-size (cadr args))
                (cadr args))
        (loop (crc-string 'ieee-32
                          (string (integer->char-ur (bit-and size #xFF)))
                          :init sum)
	      (bit-rsh size 8)))))
 |  
Be aware that many common CRCs use -1 as init value and invert the result. For
compatibility with other implementations you might want to try
one of the following alternatives:| (define (openpgp-crc-24 str)
  (crc-string 'radix-64-24 str :init #xB704CE))
 |  
| (define (alt1 name obj) (crc name obj :init -1))
(define (alt2 name obj) (crc name obj :final-xor -1))
(define (alt3 name obj) (crc name obj :init -1 :final-xor -1))
 |  |  
Bigloo provides means to create additional CRCs: one can either simply provide
a new polynomial or use Bigloo's low level functions. 
| 
Adds the given CRC to Bigloo's list. Name can be of any type (| register-crc! name poly len | bigloo procedure |  crcwill
useassocto find it in its list). The polynomial can be either a
fixnum, an elong or an llong.lenshould give the CRCs size. The
type of the polynomial and the givenlenmust be consistent. On a 32 bit
machine the following CRC registration would be invalid and yield undefined
results:
 
 
As 55 is bigger than the fixnum's bit-size calling| (register-crc! 'invalid 1337 55)
 |  crcwith this CRC will
yield undefinde results. |  
| 
| crc-long::long c::char crc::long poly::long len::long | bigloo procedure |  
| crc-elong::elong c::char crc::elong poly::elong len::long | bigloo procedure |  
| crc-llong::llong c::char crc::llong poly::llong len::long | bigloo procedure |  
| crc-long-le::long c::char crc::long poly::long len::long | bigloo procedure |  
| crc-elong-le::elong c::char crc::elong poly::elong len::long | bigloo procedure |  
These function perform a CRC operation on one byte. The previously described functions
are based on these low level functions. The result of all the low level functions
will return values that are not cut to the correct length. Usually a crc is done in
a loop, and one needs to| crc-llong-le::llong c::char crc::llong poly::llong len::long | bigloo procedure |  bit-andonly when returning the result.
Polynomials can be given with or without the high-order bit.
 For instance we could implement
 openpgp-crc24as follows:
| (define *openpgp-init* #xB704CE)
(define *radix-64-24-poly* #x864CFB)
(define (openpgp-crc-24 str)
  (let loop ((i 0)
             (crc *openpgp-init*))
    (if (=fx i (string-length str))
        (bit-and crc #xFFFFFF) ;; cut to correct length (24 bits)
        (loop (+fx i 1)
              (crc-long (string-ref str i) crc *radix-64-24-poly* 24)))))
 |  |  
| 
Returns the little endian variant of a given polynomial.| crc-polynomial-be->le len polynomial | bigloo procedure |  |  
This section presents the Bigloo function aimed at helping internet
programming. 
 
| 
The argument| url-parse url | bigloo procedure |  urlcan either be a string or an input-port. The functionurl-parseparses the url and returns four values:
 
 Examplethe protocol,
the optional user info,
the host name,
the port number,
the absolute path
 
| (multiple-value-bind (protocol uinfo host port abspath)
   (url-parse "http://www.inria.fr/sophia/teams/indes/index.html")
   (list protocol uinfo host port abspath))
      => ("http" #f "www.inria.fr" 80 "/sophia/teams/indes/index.html'')
(multiple-value-bind (protocol uinfo host port abspath)
   (url-parse "https://foo:bar@www.inria.fr/sophia/teams/indes/index.html")
   (list protocol uinfo))
      => ("https" "foo@bar")
 |  |  
| 
The argument| url-sans-protocol-parse url protocol | bigloo procedure |  urlcan either be a string or an input-port.
 This function behaves as
 url-parseexcept it assumes that the protocol
part of the url has already been extracted from the URI. It is explicitly
provided using theprotocolargument. |  
| 
The argument| http-url-parse url | bigloo procedure |  urlcan either be a string or an input-port. Asurl-parse, it returns four values.
 This function parses URL found in HTTP GET responses.
 |  
| 
Encode a path that can be used in valid URL.| url-path-encode path | bigloo procedure |  
 
 
| (url-path-encode "/tmp/foo") => "/tmp/foo"
(url-path-encode "/tmp/foo&bar") => "/tmp/foo%26bar"
(url-path-encode "http:///tmp/foo") => "http%3A//tmp/foo"
 |  |  
| 
| url-encode url | bigloo procedure |  
| uri-encode url | bigloo procedure |  
Encode a URL by removing any illegal character.| uri-encode-component url | bigloo procedure |  
 
 
| (url-encode "http:///tmp/foo") => "http://tmp:80/foo"
(url-encode "http:///tmp/foo&bar") => "http://tmp:80/foo%26"
 |  |  
| 
| url-decode url | bigloo procedure |  
| url-decode! url | bigloo procedure |  
| uri-decode url | bigloo procedure |  
| uri-decode! url | bigloo procedure |  
| uri-decode-component url | bigloo procedure |  
Decode a URL. The function| uri-decode-component! url | bigloo procedure |  url-decode!may return its argument
unmodified if no decoding is for the URL.
 The variants
 -componenttreat do not escape URI reserved characters
(i.e., #, /, ?, :, @, &, =, +, and $). |  
| 
[:protocol 'http] [:method 'get]
                               [:timeout 0] [:proxy #f]
                               [:host "localhost"] [:port 80]
                               [:path "/"] 
                               [:login #f] [:authorization #f]
                               [:username #f] [:password #f]
                               [:http-version "HTTP/1.1"]
                               [:content-type #f]
                               [:connection "close"]
                               [:header '((user-agent: "Mozilla/5.0"))]
                               [:args '()]
                               [:body #f]| http [:in #f] [:out #f] [:socket #f] | bigloo procedure |  
 Opens an HTTP connection. Returns a socket.
 
 It is an error to specify a header twice. In particular, it is illegal
to re-define keyword-ed arguments in the
 :headerlist. For instance,
it is illegal to include in the:headeractual list value a 
value for theConnectionHTTP connection.
 
 
The optional argument| (define (wget url)
   
   (define (parser ip status-code header clen tenc)
      (if (not (and (>=fx status-code 200) (<=fx status-code 299)))
	  (case status-code
	     ((401)
	      (raise (instantiate::&io-port-error
			(proc 'open-input-file)
			(msg "Cannot open URL, authentication required")
			(obj url))))
	     ((404)
	      (raise (instantiate::&io-file-not-found-error
			(proc 'open-input-file)
			(msg "Cannot open URL")
			(obj url))))
	     (else
	      (raise (instantiate::&io-port-error
			(proc 'open-input-file)
			(msg (format "Cannot open URL (~a)" status-code))
			(obj url)))))
	  (cond
	     ((not (input-port? ip))
	      (open-input-string ""))
	     (clen
	      (input-port-fill-barrier-set! ip (elong->fixnum clen))
	      ip)
	     (else
	      ip))))
   
   (multiple-value-bind (protocol login host port abspath)
      (url-parse url)
      (let* ((sock (http :host host :port port :login login :path abspath))
	     (ip (socket-input sock))
	     (op (socket-output sock)))
	 (with-handler
	    (lambda (e)
	       (if (isa? e &http-redirection)
                   (with-access::&http-redirection e (url)
		      (wget url))
		   (raise e)))
	    (read-string (http-parse-response ip op parser))))))
 |  argsis used forpostmethod. The actual
value should be a list of lists. Each of these sublists must have two values:
 
 The argument name can be either a string which is the name of the
argument or a list of two elements. In that case, the first element of
these list is the argument name. The second element should be a string
that denotes additional parameter.the argument name
the argument actual value
 
 Example:
 
 
 
An http connection blocks until the connection is established. If the
optional argument| (http :host "localhost" :port 8080 :method 'post
   :header '((enctype: "multipart/form-data"))
   :args `(("x" "foo") (("foo.scm" "filename=\"foo.scm\"\nContent-type: application/octet-stream" ,(with-input-from-file "foo.scm" read-string))))
   ...)
 |  timeoutis provided, the connection must be
established before the specified time interval elapses. The timeout
is expressed in microseconds. |  
| 
| http-read-line input-port | bigloo procedure |  
Reads a line or an end-of-line of an HTTP response.| http-read-crlf input-port | bigloo procedure |  |  
| 
Parses the status-line of an HTTP response. This returns a three values:| http-parse-status-line input-port | bigloo procedure |  
 
 The http version
The status code
the explanation phrase
 
 
 |  
| 
Parses the whole header of an HTTP response. It returns multiple values
which are:| http-parse-header input-port output-port | bigloo procedure |  the whole header as an alist.
the host given in the hostheader.the port given hostfield.the optional content-lengthheader field.the optional transfer-encodingheader field.the optional authorizationheader field.the optional proxy-authorizationheader field.the optional connectionheader field.
 |  
| 
Parses the whole response of an HTTP request. The argument| http-parse-response input-port output-port procedure | bigloo procedure |  procedureis invoked with five arguments:
 
 the input port to read the characters of the response,
the status code,
the header of the response,
the content length,
the type encoding.
 |  
| 
Parses an HTTP response and build an output port that delivers the 
characters of the content.| http-response-body->port input-port output-port | bigloo procedure |  |  
| 
| http-chunks->procedure input-port | bigloo procedure |  |  
| 
| http-chunks->port input-port | bigloo procedure |  |  
| 
| http-send-chunks input-port output-port | bigloo procedure |  |  |