Discussion of Common Lisp
-
mcheema
- Posts: 7
- Joined: Mon Nov 05, 2012 3:58 am
Post
by mcheema » Sun Dec 16, 2012 6:24 am
I was curious about the difference if any between something like
and
which is preferred?
-
nuntius
- Posts: 538
- Joined: Sat Aug 09, 2008 10:44 am
- Location: Newton, MA
Post
by 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.
-
mcheema
- Posts: 7
- Joined: Mon Nov 05, 2012 3:58 am
Post
by mcheema » Sun Dec 16, 2012 4:58 pm
nice explanations thx