━━━━━━━━━━━━━━━━━━━━━━━━ PLN CDR DRAFT: ISSUE 8 Gleefre ━━━━━━━━━━━━━━━━━━━━━━━━ 1 Issue 8 (Interaction with FORMAT) ═══════════════════════════════════ /by |3b|/ 1.1 Description ─────────────── It is not clear how /local nicknames/ should affect the tilde slash `\~//' directive of `format'. 1.2 Notes ───────── • If `\~//' directive wasn't affected by /local nicknames/, it would mean that using [long and not-so-easy-to-use] package names is necessary. • It would be counterintuitive if the function used by the `\~//' directive could change based on the /current package/ at *execution time* (that is, if the symbol lookup was affected by /local nicknames/ of the /current package/). This could also break existing code if a /local nickname/ in the /current package/ shadows the name of a package containing a function used in a format control string in the called function. The only way to prevent this issue would be to rebind the `*package*' variable around any call to `format' where the `\~//' directive is used. • Finally, if the call to `format' is not compiled, it would be hard to impossible to find the function using /local nicknames/ of the package that was the /current package/ at *compile time*. 1.3 Examples ──────────── ┌──── │ (defpackage #:foo-a (:use) (:export #:ff)) │ (defpackage #:foo-b (:use) (:export #:ff)) │ │ (defun foo-a:ff (stream &rest args) │ (declare (ignore args)) │ (format stream "FOO-A:FF")) │ │ (defun foo-b:ff (stream &rest args) │ (declare (ignore args)) │ (format stream "FOO-B:FF")) │ │ (defpackage #:bar-a │ (:use #:cl) │ (:local-nicknames (#:nick #:foo-a))) │ │ (defpackage #:bar-b │ (:use #:cl) │ (:local-nicknames (#:nick #:foo-b))) │ │ (in-package #:bar-a) │ │ (defun test () │ (format t "Called ~/nick:ff/ & " nil) │ (let ((*package* (find-package (quote #:bar-a)))) ; or #.*package* │ (format t "~/nick:ff/~%" nil))) │ │ (test) │ ; => "Called FOO-A:FF & FOO-A:FF" (sbcl, ccl, ecl, acl, abcl, clasp) │ ; lispworks errors (NICK package not found) │ (let ((*package* (find-package (quote #:bar-b)))) │ (test)) │ ; => "Called FOO-A:FF & FOO-A:FF" (sbcl, clasp) │ ; => "Called FOO-B:FF & FOO-A:FF" (ccl, ecl, acl, abcl) │ ; lispworks errors (NICK package not found) └──── 1.4 Proposal NOT-AFFECTED-BY-LOCAL-NICKNAMES ──────────────────────────────────────────── The tilde slash `\~//' directive of `format' must *not* use /local nicknames/ of any package when looking up the specified symbol. 1.4.1 Rationale ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ When the package prefix is not specified, the specified symbol is not looked up in the /current package/, but instead in the `#:CL-USER' package. That suggests that the tilde slash `\~//' directive should not depend on the value of `*package*' at any time. Note that specifying it to use /local nicknames/ of the `#:CL-USER' package would risk breaking the existing code, since it is allowed to add local nicknames to the `#:CL-USER' package. 1.5 Links ───────── See [CLHS 22.3.5.4 Tilde Slash: Call Function]. [CLHS 22.3.5.4 Tilde Slash: Call Function]