Re: documentation on putp/getp
Leon Bottou <[email protected]>
| Newsgroups | gmane.lisp.lush.devel |
|---|---|
| Message-ID | <[email protected]> |
On Friday 04 March 2005 01:46 pm, Ralf Juengling wrote: > > ? ^Aputp > > ------------------------------------------------------------------------ > (putp <anything> <name> <value>) [DE](sysenv.lsh) > . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . > > Every Lush object (atoms, cons, etc.) may be enriched by defining > properties identified by a symbolic name. Function putp is used to > define such properties. Its first argument is an arbitrary Lush object > anything . Function putp sets the property named by symbol name to value > value . Properties can be later retrieved using getp . > > > Something like this should be added to the documentation: > > NOTE: Do not apply putp to temporary objects! putp increases > an object's reference counter, which will prevent a temporary > object ever to be garbage collected. Not true. ? (defclass x object) = x ? (defmethod x -destructor() (print 'destroy x))) = -destructor ? (new x) = ::x:88467f8 ? 2 ;; this erase the variable 'result' which always contains the last result = 2 destroy ::class:x ? ? (let ((y (new x))) (putp y 'info 2) y) = ::x:884b588 ? 2 = 2 destroy ::class:x ? I agree that this is not obvious when you see how getp and putp are implemented. This is because htables with == semantic also handle their keys as weak pointers. This is actually documented somewhere... ? ^Aassociations with hash - L. ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click