From: Juan Pardillos
Subject: Setting a property in a symbol.
Date: 
Message-ID: <6278687.0205260248.625d834f@posting.google.com>
Hello,

I'd like to know if there is possible in Lisp distinguish between a
situation in which a symbol has a property with nil value and a
situation in which a symbol has not such a property.

As far as I know, (get 'mySymbol 'myProperty) will return nil whether
we did before (set 'mySymbol 'myProperty nil) or no.

Any ideas?.

Thanks in advance

From: Donald Fisk
Subject: Re: Setting a property in a symbol.
Date: 
Message-ID: <3CF151A7.FB4E582@enterprise.net>
Juan Pardillos wrote:
> 
> Hello,
> 
> I'd like to know if there is possible in Lisp distinguish between a
> situation in which a symbol has a property with nil value and a
> situation in which a symbol has not such a property.
> 
> As far as I know, (get 'mySymbol 'myProperty) will return nil whether
> we did before (set 'mySymbol 'myProperty nil) or no.
> 
> Any ideas?.

Yes.   Use symbol-plist, or a function which calls it:

[1]> (symbol-plist 'foo)
NIL
[2]> (get 'foo 'bar)
NIL
[3]> (setf (get 'foo 'bar) nil)
NIL
[4]> (symbol-plist 'foo)
(BAR NIL)
[5]> (get 'foo 'bar)
NIL

> Thanks in advance

-- 
Le Hibou
You know you've been hacking too long if, when someone
asks you if you have a son, you reply, "No, but I've
got a Symbolics 3630".
From: Adam Warner
Subject: Re: Setting a property in a symbol.
Date: 
Message-ID: <acqfj1$oua95$1@ID-105510.news.dfncis.de>
On Sun, 26 May 2002 22:48:23 +1200, Juan Pardillos wrote:

> Hello,
> 
> I'd like to know if there is possible in Lisp distinguish between a
> situation in which a symbol has a property with nil value and a
> situation in which a symbol has not such a property.
> 
> As far as I know, (get 'mySymbol 'myProperty) will return nil whether we
> did before (set 'mySymbol 'myProperty nil) or no.
> 
> Any ideas?.

http://www.xanalys.com/software_tools/reference/HyperSpec/Body/f_get.htm

   There is no way using get to distinguish an absent property from one
   whose value is default. However, see get-properties.

http://www.xanalys.com/software_tools/reference/HyperSpec/Body/f_get_pr.htm#get-properties

   get-properties is used to look up any of several property list entries
   all at once.

   It searches the plist for the first entry whose indicator is identical
   to one of the objects in indicator-list. If such an entry is found, the
   indicator and value returned are the property indicator and its
   associated property value, and the tail returned is the tail of the
   plist that begins with the found entry (i.e., whose car is the
   indicator). If no such entry is found, the indicator, value, and tail
   are all nil.

Regards,
Adam
From: Erik Naggum
Subject: Re: Setting a property in a symbol.
Date: 
Message-ID: <3231410756403264@naggum.net>
* Adam Warner
| There is no way using get to distinguish an absent property from one
| whose value is default.

  Yes, there is.  Let the default value be a fresh or unique object.  This
  is pretty obvious, so a much better solution to the whole problem is this
  shadowing redefinition of the standard function:

(shadow 'get)
(defun get (symbol property &optional default)
  (let* ((fresh (cons t t))
         (prop (cl:get symbol property fresh)))
    (if (eq fresh prop)
      (values default nil)
      (values prop t))))

  If this function should not cons, wrap (cons t t) in a load-time-value.
-- 
  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.

  70 percent of American adults do not understand the scientific process.
From: Adam Warner
Subject: Re: Setting a property in a symbol.
Date: 
Message-ID: <acqrag$r9pmf$1@ID-105510.news.dfncis.de>
On Mon, 27 May 2002 02:05:58 +1200, Erik Naggum wrote:

> * Adam Warner
> | There is no way using get to distinguish an absent property from one |
> whose value is default.
> 
>   Yes, there is.

Please tell that to the ANSI Common Lisp specification then Erik. That's
where the sentence comes from.

Regards,
Adam
From: Erik Naggum
Subject: Re: Setting a property in a symbol.
Date: 
Message-ID: <3231413257078546@naggum.net>
* Adam Warner
| Please tell that to the ANSI Common Lisp specification then Erik.

  Please read the rest of my article, Adam.  I have actually tried to
  answer your problem and point to a solution.  I have implicitly asked you
  to think.  Now I ask you explicitly: If you insist on behaving stupidly,
  I must conclude that you are no longer interested in a solution, if you
  ever where, but in arguing and quibbling.  I am interested in solving
  problems, but some people are so dead set on being personally "right"
  that they lose track of their problem.  Which is more important to you:
  Having _been_ right by insisting on your past understanding or _becoming_
  right by learning and thinking?  If you do not display some evidence of
  actual thinking if you choose to respond, you will get the last word.
-- 
  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.

  70 percent of American adults do not understand the scientific process.
From: Adam Warner
Subject: Re: Setting a property in a symbol.
Date: 
Message-ID: <acr0nb$pso8l$1@ID-105510.news.dfncis.de>
On Mon, 27 May 2002 02:47:45 +1200, Erik Naggum wrote:

> * Adam Warner
> | Please tell that to the ANSI Common Lisp specification then Erik.
> 
>   Please read the rest of my article, Adam.  I have actually tried to
>   answer your problem and point to a solution.  I have implicitly asked
>   you to think.  Now I ask you explicitly: If you insist on behaving
>   stupidly, I must conclude that you are no longer interested in a
>   solution, if you ever where, but in arguing and quibbling.  I am
>   interested in solving problems, but some people are so dead set on
>   being personally "right" that they lose track of their problem.  Which
>   is more important to you: Having _been_ right by insisting on your
>   past understanding or _becoming_ right by learning and thinking?  If
>   you do not display some evidence of actual thinking if you choose to
>   respond, you will get the last word.

Thank you for your ingenious solution Erik. I guess I just got a little
hurt since you called my previous reply bogus when it was a fair attempt
by someone new to Lisp (-like languages) to compare it with Scheme.

My main attempt in this thread was to point out where some of the
"solutions" can be found in the HyperSpec. I am yet to use `get' myself!

I didn't appreciate the condescending reply. It's not endearing. But I've
read enough of the archives to expect it. Perhaps I subconsciously just
wanted to get it over with :-)

Regards,
Adam
From: Erik Naggum
Subject: Re: Setting a property in a symbol.
Date: 
Message-ID: <3231422371368070@naggum.net>
* Adam Warner <······@consulting.net.nz>
| Thank you for your ingenious solution Erik. I guess I just got a little
| hurt since you called my previous reply bogus when it was a fair attempt
| by someone new to Lisp (-like languages) to compare it with Scheme.

  Well, I think comparing Common Lisp to Scheme is prima facie evidence of
  ill will, even if Common Lisp wins.  It is somewhat like a supposed
  compliment like "man, you are even smarter than George W. Bush".

| I didn't appreciate the condescending reply.

  No condescension was intended.  Brevity, perhaps even harshness, but no
  condescension.

| It's not endearing.  But I've read enough of the archives to expect it.
| Perhaps I subconsciously just wanted to get it over with :-)

  Unfortunately, this is more common than _my_ actually being nasty to
  anyone.  The sort of preparatory defense in case I hurt someone is even
  more idiotic than the things I generally get pissed off by, but I am very
  happy that you are aware of some weak tendencies in that direction and
  chose to respond differently.  Thank you.
-- 
  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.

  70 percent of American adults do not understand the scientific process.