| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A weak pointer is a reference to an object that doesn't prevent
the object from being garbage-collected.
Gauche provides weak pointers as a weak vector object.
A weak vector is like a vector of objects, except each object
can be garbage collected if it is not referenced from objects
other than weak vectors. If the object is collected, the
entry of the weak vector is replaced for #f.
gosh> (define v (make-weak-vector 1)) v gosh> (weak-vector-ref v 0) #f gosh> (weak-vector-set! v 0 (cons 1 1)) #<undef> gosh> (weak-vector-ref v 0) (1 . 1) gosh> (gc) #<undef> gosh> (gc) #<undef> gosh> (weak-vector-ref v 0) #f |
The weak vector class. Inherits <sequence> and <collection>,
so you can use
gauche.collection (See section gauche.collection - Collection framework) and
gauche.sequence (See section gauche.sequence - Sequence framework).
(coerce-to <weak-vector> '(1 2 3 4)) ⇒ a weak vector with four elements |
Creates and returns a weak vector of size size.
Returns the length of a weak vector wvec.
Returns k-th element of a weak vector wvec.
By default, weak-vector-ref signals an error if k is
negative, or greater than or equal to the size of wvec.
However, if an optional argument fallback is given,
it is returned for such case.
If the element has been garbage collected, this procedure returns
fallback if it is provided, #f otherwise.
With gauche.sequence module,
you can also use a method ref.
Sets k-th element of the weak vector wvec to obj. It is an error if k is negative or greater than or equal to the size of wec.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated by Shiro Kawai on October, 7 2008 using texi2html 1.78.