what is difference between : and :#

Discussion of Common Lisp

what is difference between : and :#

Postby mcheema » Sun Dec 16, 2012 6:24 am

I was curious about the difference if any between something like
Code: Select all
(defpackage :dummy
(:use :cl))

and
Code: Select all
(defpackage #:dummy
(:use #:cl))


which is preferred?
mcheema
 
Posts: 3
Joined: Mon Nov 05, 2012 3:58 am

Re: what is difference between : and :#

Postby nuntius » Sun Dec 16, 2012 11:32 am

:word creates a symbol in the keyword package; it will remain during the life of your program.
#:word creates a symbol in no package; it will presumably be garbage collected after use.

In both cases, symbol-name is used to create a new symbol (by name). The benefit of using these instead of "word" is that they undergo the default case translation whereas a string literal does not.

Thus there is a minor memory benefit to using #:word.
User avatar
nuntius
 
Posts: 497
Joined: Sat Aug 09, 2008 10:44 am
Location: Burlington, MA

Re: what is difference between : and :#

Postby mcheema » Sun Dec 16, 2012 4:58 pm

nice explanations thx
mcheema
 
Posts: 3
Joined: Mon Nov 05, 2012 3:58 am


Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 3 guests