From: Ron Garret on
In article
<a06fc1e0-aa10-43f3-bd8c-d52032178c7c(a)5g2000yqj.googlegroups.com>,
Pillsy <pillsbury(a)gmail.com> wrote:

> 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.

That's a pretty bad habit. Why not:

(format nil "~A~A" :make name)

or

(format nil "~A~A" "MAKE" name)

or

(format nil "MAKE~A" name)

or

(concatenate 'string "MAKE" (string name))

rg
From: Tim Bradshaw on
On 2010-04-06 15:38:00 +0100, Ron Garret said:
>
> Yes, but in those cases you don't need uninterned symbols. Keywords
> work just fine. In fact, that is what keywords are for.

Some people don't like interning a large number of symbols they don't
need for things like package export lists and so on.

>
> 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.
>

What you are often doing is saving yourself a lot of typing.

From: Captain Obvious on
??>> Um, I don't remember any system definitions which need lots of string
??>> designators.

ZB> They're used for the system's name, and for naming :depends-on
ZB> components that are other systems, e.g.

Well, yep, it needs some of them, but that doesn't qualify as "lots" IMHO.

From: Ron Garret on
In article <8239z8zkto.fsf(a)netfonds.no>,
"Frode V. Fjeld" <frode(a)netfonds.no> wrote:

> > 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)

This example is one of the few legitimate uses of an uninterned symbol,
and it is legitimate precisely *because* you *want* to break READ-READ
consistency to insure that #0# is returned ONLY on end-of-file and under
no other circumstances. But there is nothing special about *symbols*
for this application. *Any* uninterned object will do. You could just
as well have written:

(read nil nil '#0=(list 'eof))

or

(let ((eof #:eof))
(loop for x = (read nil nil eof)
until (eq x eof)
...

or

(let ((eof (list :eof))) ...

or

(let ((eof (make-symbol "EOF"))) ...

or

(let ((eof (make-instance 'end-of-file-marker))) ...

Which is better is a matter of taste. Personally I hate #N= reader
syntax because I think it's horribly unreadable. But a reasonable
person could disagree.

rg
From: Tim Bradshaw on
On 2010-04-06 15:30:14 +0100, Ron Garret said:

>
> It's better to use keywords because they also meet all these
> requirements, and they also introduce less syntactic clutter and don't
> break read-read consistency like #: does.

I should have said "don't want to intern a symbol in any package" not
"whatever package is current".