Subject: FORMAT ~/NAME/ [was: ... "mapconcat" ... ]
From: (Rob Warnock)
Date: Wed, 15 Jul 2009 02:23:31 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
Pascal J. Bourguignon <> wrote:
| Madhu <> writes:
| > This is the easiest clearest way to solve the problem with the
| > mechanism provided by the tilde-slash directive.  You _have_ to
| > have a global function in CL-USER because the spec demands it.  
| Actually, this is wrong.
| C/USER[411]> (defpackage "F" (:use "CL") (:export "X"))
| C/USER[412]> (defun F:X (stream object &rest args) (princ "X" stream))
| F:X
| C/USER[413]> (format t "~/F:X/" 'toto)
| X
| C/USER[414]> 

By the way, have you ever noticed that ~/NAME/ violates the ":"/"::"
reader protocol for "external/internal" symbol indication?

    > (defpackage "F" (:use "CL"))

    #<The F package, 0/9 internal, 0/2 external>
    > (defun F::X (stream object &rest args)
	(declare (ignorable object args))
	  (princ "X" stream))

    > (format t "~/F::X/" 'toto)  ; This I expected to work.
    > (format t "~/F:X/" 'toto)   ; This I didn't.

And, no, I didn't accidentally make X external:   ;-}

    > (find-symbol "X" "F")

    > (ignore-errors (read-from-string "F::X"))

    > (ignore-errors (read-from-string "F:X"))  ; Error expected here.


Anyway, as odd as this is, the CLHS seems to require it: Tilde Slash: Call Function
    If NAME contains a single colon (:) or double colon (::), then
    everything up to but not including the first ":" or "::" is taken
    to be a string that names a package. Everything after the first
    ":" or "::" (if any) is taken to be a string that names a symbol.
    The function corresponding to a ~/NAME/ directive is obtained by
    looking up the symbol that has the indicated name in the indicated

Notice that the lookup is *not* described in terms of READ of
the whole name, but rather as a FIND-SYMBOL or INTERN of the
pieces of NAME separately. Anybody know why?


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607