Re: documentation on putp/getp

Ralf Juengling <[email protected]>
Newsgroups gmane.lisp.lush.devel
Message-ID <[email protected]>
On Fri, 2005-03-04 at 11:25, Leon Bottou wrote:
> On Friday 04 March 2005 01:46 pm, Ralf Juengling wrote:
> [...bla about putp/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

[...]

* Hash tables can also rely on pointer equality, as implemented by
  function == . These hash tables are useful to associate a piece of
  information with a particular lisp object. Functions getp and putp ,
  for instance, make use of pointer-equality hash tables. The
  associations of a pointer-equality hash table are automatically
  removed when the key object is deallocated.

I'm confused.
You and the hash table documentation are talking about the key 
object that gets dereferenced, whereas in the example above it's 
value object that gets dereferenced. 
You then just exhibited a documentation bug? (Note also that only
symbols are allowed as keys for putp/getp).

thanks,
ralf




-------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.