Re: documentation on putp/getp

Leon Bottou <[email protected]>
Newsgroups gmane.lisp.lush.devel
Message-ID <[email protected]>
On Friday 04 March 2005 09:14 pm, Ralf Juengling wrote:
> On Fri, 2005-03-04 at 17:59, Ralf Juengling wrote:
> > [...]
> > 
> > * 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).

> What is the object for putp is the key for the hidden hash table 
> that encodes the association.

It is all implemented in sys/sysenv.lsh


(defvar |*PROPERTIES| (htable))

(de getp(obj key)
  (let ((data (|*PROPERTIES| key)))
    (when data (data obj)) ) )

(de putp(obj key val)
  (let ((data (|*PROPERTIES| key)))
    (when (not data)
      (when (symbolp key)
        (|*PROPERTIES| key (setq data (htable 17 t))) )
      (when (not data)
        (error 'putp "not a symbol" key) ) )
    (data obj val)
    key ) )


The hash table |*PROPERTIES| maps each putp/getp 
symbol key to a second htable with pointer equality.
The keys of this second htable are the putp/getp objects
with a propertie for that object. 

- 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
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.