Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

use of colon

2 views
Skip to first unread message

Mario Frasca

unread,
Oct 17, 2000, 3:00:00 AM10/17/00
to
Is one colon or two correct when separating package and symbol?

USER(13): (export 'bar)
T
USER(14): (in-package mine)
#<The MINE package>
MINE(15): user:bar
4
MINE(16): user::bar
4
MINE(17): user:non-existant
Error: Symbol "NON-EXISTANT" not found in the COMMON-LISP-USER package.
[condition type: READER-ERROR]
[1] MINE(18): :res
MINE(19): user::non-existant
Error: Attempt to take the value of the unbound variable
`COMMON-LISP-USER::NON-EXISTANT'.
[condition type: UNBOUND-VARIABLE]

Restart actions (select using :continue):
0: Try evaluating COMMON-LISP-USER::NON-EXISTANT again.
1: Set the symbol-value of COMMON-LISP-USER::NON-EXISTANT and use its value.
2: Use a value without setting COMMON-LISP-USER::NON-EXISTANT.
3: Return to Top Level (an "abort" restart)
[1] MINE(20): :res
MINE(21):

so there is a difference... or there's not?

also 'ANSI Common Lisp' by Graham leaves me in doubt, look at page 238,
where both forms are used (three times ':', once '::').

Barry Margolin

unread,
Oct 17, 2000, 3:00:00 AM10/17/00
to
In article <slrn8uonmo...@tamino.cs.uu.nl>,

Mario Frasca <ma...@cs.uu.nl> wrote:
>Is one colon or two correct when separating package and symbol?

One is enough for external symbols, two are required to access internal
symbols. Usually you shouldn't need to access internal symbols, so if you
need to use two colons you should think hard about whether you really
should be calling that function.

--
Barry Margolin, bar...@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

Rainer Joswig

unread,
Oct 17, 2000, 3:00:00 AM10/17/00
to
In article <slrn8uonmo...@tamino.cs.uu.nl>, ma...@cs.uu.nl
(Mario Frasca) wrote:

> Is one colon or two correct when separating package and symbol?
>

You need to read a bit about packages in Lisp.

FOO::BAR references the symbol named "BAR" in package FOO.

FOO:BAR FOO::BAR references the symbol named "BAR" in package FOO,
if FOO exports this symbol. Otherwise it is an error.

Usually exporting a symbol indicates that it is belongs
to an interface of a piece software. If it is
not exported, the original author usually means that it
is not wise to use it outside of this package directly.
Common Lisp provides this mechanism to hide symbols,
but in a long tradition, there is a way to directly
reference non-exported symbols. Some "modern"
"software-engineers" sure wouldn't like it. ;-)

--
Rainer Joswig, Hamburg, Germany
Email: mailto:jos...@corporate-world.lisp.de
Web: http://corporate-world.lisp.de/

0 new messages