From: Zach Beane on 6 Apr 2010 10:42 Ron Garret <rNOSPAMon(a)flownet.com> writes: > In article <87k4skslja.fsf(a)hangup.portland.xach.com>, > Zach Beane <xach(a)xach.com> wrote: > >> Ron Garret <rNOSPAMon(a)flownet.com> writes: >> >> > you should NEVER use #: because it breaks READ-READ consistency (see >> > CLHS 2.3.6). If you need an uninterened symbol with a particular name >> > you should call MAKE-SYMBOL directly to make it clear what is going >> > on. >> >> For DEFPACKAGE, IN-PACKAGE, ASDF:DEFSYSTEM, etc., the uninterned symbol >> is used only for the string it designates, and it is not evaluated. > > Yes, but in those cases you don't need uninterned symbols. Keywords > work just fine. In fact, that is what keywords are for. Uninterned symbols work perfectly fine, too. > This is exactly why you should never use #: syntax. It is extremely > rare that you actually need an uninterned symbol with a particular name. > If you find yourself thinking that #:FOO is more appropriate than > (MAKE-SYMBOL "FOO") or #.(MAKE-SYMVBOL "FOO") you are almost certainly > doing something wrong. This isn't persuasive. Zach
From: Captain Obvious on 6 Apr 2010 10:51 TKP> I am not completely clear on the applications of the #: read macro for TKP> uninterned symbols. If you need symbol only for its name, then interning it into some package is sub-optimal, both from memory footprint perspective and from "namespace pollution" perspective -- those symbols will show up in output of apropos and completions in IDE among useful symbols, and that might slow down your development process. In practice, if you make just few symbols, it just doesn't matter. If you make lots of them -- say, hundred -- it sort of matters already. E.g. if you use a keyword symbol for package name, that's ok -- because usually you don't have lots of packages, and also you might want completion to work on package names. But if you use keyword symbols for exports and imports in defpackage, declaration, that might introduce potentially a lot of unwanted symbols. TKP> in-package, and other forms), but AFAIK ASDF loading happens in a TKP> temporary package anyway, so it should not be necessary. TKP> Nevertheless, I have seen ASDF files peppered with #: all over the TKP> place, so maybe I am mistaken. Um, I don't remember any system definitions which need lots of string designators. But files like package.lisp need to name symbols, are you sure you're not confusing system defintions with package definitions?
From: Zach Beane on 6 Apr 2010 10:55 "Captain Obvious" <udodenko(a)users.sourceforge.net> writes: > TKP> in-package, and other forms), but AFAIK ASDF loading happens in a > TKP> temporary package anyway, so it should not be necessary. > TKP> Nevertheless, I have seen ASDF files peppered with #: all over the > TKP> place, so maybe I am mistaken. > > Um, I don't remember any system definitions which need lots of string > designators. They're used for the system's name, and for naming :depends-on components that are other systems, e.g. (asdf:defsystem #:fribble :depends-on (#:zot #:blarp #:wibble) ...) Zach
From: Frode V. Fjeld on 6 Apr 2010 11:01 > In article <87k4skslja.fsf(a)hangup.portland.xach.com>, > Zach Beane <xach(a)xach.com> wrote: >> >> For DEFPACKAGE, IN-PACKAGE, ASDF:DEFSYSTEM, etc., the uninterned >> symbol is used only for the string it designates, and it is not >> evaluated. Ron Garret <rNOSPAMon(a)flownet.com> writes: > Yes, but in those cases you don't need uninterned symbols. Keywords > work just fine. In fact, that is what keywords are for. I don't think that's true. I believe keywords are typically used for their identity, whereas (literal) uninterned symbols are usually used for their name, and occationally for their identity, for example like this: (loop for x = (read nil nil '#0=#:eof) until (eq x '#0#) collect x) -- Frode V. Fjeld
From: Pillsy on 6 Apr 2010 11:07
On Apr 6, 5:31 am, Tamas K Papp <tkp...(a)gmail.com> wrote: > I am not completely clear on the applications of the #: read macro for > uninterned symbols. Redshank inserts it everywhere before symbols > (defsystem, in-package, and other forms), but AFAIK ASDF loading > happens in a temporary package anyway, so it should not be necessary. > Nevertheless, I have seen ASDF files peppered with #: all over the place, > so maybe I am mistaken. > When is it "good style"/recommended to use #:? I use them exclusively as string designators in DEFPACKAGE forms, though their advantages over keywords are marginal. I got into the habit very early on, before I really understood how packages and symbols worked, because I saw someone else do it and immitated it and all the problems I was having using symbols interned in whatever package I evaluated the DEFPACKAGE form went away. Another place I'll use them is when I'm using format to build interned symbols in macros. For example, I'll often have things like (defmacro deffrob (name &body stuff) `(progn (defun ,(intern (format nil "~A~A" '#:make name)) () ... Again, this is more habit than anything else. Cheers, Pillsy |