Pascal J. Bourguignon <firstname.lastname@example.org> wrote:
| Madhu <email@example.com> 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> (defpackage "F" (:use "CL") (:export "X"))
| #<PACKAGE F>
| C/USER> (defun F:X (stream object &rest args) (princ "X" stream))
| C/USER> (format t "~/F:X/" 'toto)
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:
220.127.116.11 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 <firstname.lastname@example.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607