/usr/share/gap/lib/wpobj.gd is in gap-libs 4r6p5-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | #############################################################################
##
#W wpobj.gd GAP library Steve Linton
##
##
#Y Copyright (C) 1997,
#Y (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland
#Y Copyright (C) 2002 The GAP Group
##
## This file contains the definition of operations and functions for
## weak pointers.
##
## WP objects behave in most respects like mutable plain lists, except that
## they do not keep their subobjects alive, so that one sees things like.
##
## gap> w := WeakPointerObj([[1,2]]);;
## gap> IsBound(w[1]);
## true
## gap> GASMAN("collect");
## gap> w;
## WeakPointerObj([ [ ] ]);
##
## for this reason the common idiom
##
## if IsBound(w[i]) then
## DoSomethigWith(w[i]);
## fi;
##
## is not really safe.
##
## A solution is provided by the kernel function ElmWPObj (weakptr.c), which
## returns fail if the entry is (1) unbound or (2) bound to the value fail.
## Since fail will never be collected as garbage, a subsequent call to IsBound
## can safely be used to distinguish these two cases, as in:
##
## x := ElmWPObj(w,i);
## if x <> fail or IsBound(w[i]) then
## DoSomethingWith(x);
## else
## DoSomethingElse();
## fi;
##
#############################################################################
##
##
#C IsWeakPointerObject( <obj> ) . . . . . . . . . . category of WP objects
##
## All WP objects have to be mutable (a stronger term like volatile would
## be appropriate),
## but this cannot be expressed via an explicit implication;
## note that `Immutable' is handled by the kernel.
##
DeclareCategoryKernel( "IsWeakPointerObject",
IsList and IsSmallList,
IsWPObj );
#############################################################################
##
#E wpobj.gd . . . . . . . . . . . . . . . . . . . . . . . . . . . ends here
##
|