In Practical Common Lisp, I read that keywork symbols and string
designators can be used to define defpackage form as follows:
(defpackage :com.gigamonkeys.email-db
(:use :common-lisp))
(defpackage "COM.GIGAMONKEYS.EMAIL-DB"
(:use "COMMON-LISP"))
I also read that #: means uninterned symbol which does not belong to
any package, like symbols generated by gensym.
When I try to read real code, for example, lisp-unit or weblocks, I
saw that #: is used to define defpackage form. I merely guess its
purpose is to avoid name conflict. But I'm not sure. And if each time
the reader reads a #: name, it creates a new symbol, then #:lisp-unit
in defpackage and #:lisp-unit in in-package represent different
symbols, I guess. But that's not make sense.
(cl:defpackage #:lisp-unit
(:use #:common-lisp)
(:export #:define-test #:run-all-tests #:run-tests ...
(in-package #:lisp-unit)
(defpackage #:weblocks-asd
(:use :cl :asdf)
(:nicknames :wop)
(:export #:test #:test-op #:doc #:doc-op #:make-app #:make-app-op))
(defpackage :com.gigamonkeys.text-db
(:use :common-lisp)
(:export :open-db
:save
:store))
What are the differences of purpose between #: and : in the above
examples? Thanks in advance.
Chanwoo Yoo <·········@gmail.com> writes:
> [...]
> When I try to read real code, for example, lisp-unit or weblocks, I
> saw that #: is used to define defpackage form. I merely guess its
> purpose is to avoid name conflict. But I'm not sure. And if each time
> the reader reads a #: name, it creates a new symbol, then #:lisp-unit
> in defpackage and #:lisp-unit in in-package represent different
> symbols, I guess. But that's not make sense.
Both #1=#:abc and #2=#:abc designate the same strings, "ABC" and "ABC"
and "ABC" and ...
Try:
(values (string= '#:abc '#:abc)
(string= '#:abc ':abc)
(string= '#:abc 'abc)
(string= '#:abc '"ABC"))
--
__Pascal_Bourguignon__ _ Software patents are endangering
() ASCII ribbon against html email (o_ the computer industry all around
/\ 1962:DO20I=1.100 //\ the world http://lpf.ai.mit.edu/
2001:my($f)=`fortune`; V_/ http://petition.eurolinux.org/
* Chanwoo Yoo<····································@z17g2000hsg.googlegroups.com> Wrote on Sat, 5 Jan 2008 17:50:57 -0800 (PST):
|
| What are the differences of purpose between #: and : in the above
| examples? Thanks in advance.
This was just discussed this last week.
See the thread titled "A Question about DEFPACKAGE syntax" on
comp.lang.lisp starting at Andreas Davour's article[1]
<····················@Psilocybe.Update.UU.SE>
<URL:HTTP:groups.google.com/group/comp.lang.lisp/browse_thread/thread/4a8f0f8bb30d6dea/2a5d97d8cb9a5141>
Personally I recommend the suggestions in[2]
<·································@news-europe.giganews.com>
<URL:http://groups.google.com/group/comp.lang.lisp/msg/2a5d97d8cb9a5141>
--
Madhu
For the google impaired the Message IDs are:
[1] (cs9abnva18l.fsf @ Psilocybe.Update.UU.SE)
[2] (joswig-00E937.17570928122007 @ news-europe.giganews.com)