From: Rommel Martinez
Subject: difference between :symbol and 'symbol
Date: 
Message-ID: <440de137.0411161922.346db8d8@posting.google.com>
Hi, what is the real difference between :symbol and 'symbol?

Thanks.

From: Peter Seibel
Subject: Re: difference between :symbol and 'symbol
Date: 
Message-ID: <m36545f883.fsf@javamonkey.com>
······@yahoo.com (Rommel Martinez) writes:

> Hi, what is the real difference between :symbol and 'symbol?

One is a keyword symbol and one is a quoted symbol in the current
package.

Keyword symbols are interned in the KEYWORD package and automatically
exported. Also each keyword symbol is automatically (in effect anyway)
defined as a constant varibles with the symbol as its value. I.e. it's
like wrote this:

  (defconstant keyword:symbol 'keyword:symbol)

Thus you can use keyword symbols in value positions and they evaluate
to themselves. In other words:

  (eql :symbol ':symbol)

'symbol on the other hand is a completely diffent symbol (unless you
happen to have *package* bound to KEYWORD which would be quite odd).

The value of the expression 'symbol is the symbol named SYMBOL in the
current package because the quote prevents evaluation.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Peter Seibel
Subject: Re: difference between :symbol and 'symbol
Date: 
Message-ID: <m3fz38e7cp.fsf@javamonkey.com>
Paul Foley <···@below.invalid> writes:

> Not quite [snip] one is a two-element list consisting of one symbol
> in the COMMON-LISP package and one in the current package.

Right, like I said: a quoted symbol in the current package. ;-) (Do
you have some *other* definition of a quoted symbol?)

To the OP: in case it's not clear, Paul and I are saying the same
thing in different ways.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: David Sletten
Subject: Re: difference between :symbol and 'symbol
Date: 
Message-ID: <J%zmd.87027$Kl3.16123@twister.socal.rr.com>
Rommel Martinez wrote:
> Hi, what is the real difference between :symbol and 'symbol?
> 
What you mean to ask is what is the difference between :SYMBOL and 
SYMBOL. The single quote in your second example is not part of SYMBOL, 
it's just a shortcut for (quote symbol). (More on that in a moment.)

The short answer is that :SYMBOL is a keyword. Keywords are constants 
which evaluate to themselves:
:symbol => :SYMBOL
Keywords are used in many functions to specify certain optional 
arguments known for obvious reasons as 'keyword arguments':
(make-string 3 :initial-element #\z) => "zzz"

Symbols in general can be used as names of variables or functions, among 
other things:
(defvar symbol 9)
When used to represent a variable, a symbol evaluates to the value of 
the variable:
symbol => 9
(Of course, this is a silly name for a variable).
If you want to refer to a symbol itself rather than its value ('mention' 
rather than 'use') you can quote it:
(quote symbol) => SYMBOL
As I mentioned above, the following does the same thing:
'symbol => SYMBOL
Note that we can also quote a keyword, but it's pointless:
':symbol => :SYMBOL

The longer answer is that :SYMBOL is an external symbol in the package 
KEYWORD. Its fully-qualified name is KEYWORD::SYMBOL. SYMBOL, on the 
other hand, is (by default) located in the package COMMON-LISP-USER, so 
its full name is COMMON-LISP-USER::SYMBOL. Try:
(describe 'keyword::symbol) and
(describe 'symbol) (The same as (describe 'common-lisp-user::symbol)).

Keywords exhibit the special properties mentioned above by virtue of 
their presence in the package KEYWORD.

David Sletten
From: Kenneth Tilton
Subject: Re: difference between :symbol and 'symbol
Date: 
Message-ID: <ktilton-426F97.23531416112004@nyctyp01-ge0.rdc-nyc.rr.com>
In article <····························@posting.google.com>,
 ······@yahoo.com (Rommel Martinez) wrote:

> Hi, what is the real difference between :symbol and 'symbol?
> 
> Thanks.

:symbol goes straight into the keyword package, and has the advantage of 
being visible from any other package without having to be exported.

'symbol will go into whatever package happens to be current, and will 
have to be exported if you do not want code in other packages to have to 
say whatever::symbol.

kenny
From: Yuji Minejima
Subject: Re: difference between :symbol and 'symbol
Date: 
Message-ID: <pan.2004.11.18.01.23.47.54830@nifty.ne.jp>
On Tue, 16 Nov 2004 19:22:35 -0800, Rommel Martinez wrote:

> Hi, what is the real difference between :symbol and 'symbol?

:symbol denotes a symbol in the keyword package.

The keyword package has some special characteristics which other
packages don't have.

See "11.1.2.3 The KEYWORD Package" in Common Lisp HyperSpec.
http://www.lispworks.com/reference/HyperSpec/Body/11_abc.htm

All symbols interned in the keyword package are automatically exported.
So you can refer them like keyword:symbol.
Although it's not specified in the standard, you can think of
the keyword package as a package having "" (null string) as its nickname.
Thus, :symbol has the same meaning as keyword:symbol.

clisp
(package-nicknames "KEYWORD") => ("")

cmucl
(package-nicknames "KEYWORD") => ()
From: Rommel Martinez
Subject: Re: difference between :symbol and 'symbol
Date: 
Message-ID: <440de137.0411182008.26cb5c3f@posting.google.com>
Thanks guys. You all have been very helpful. :-)

-Rommel