In article <·····················@twister.nyc.rr.com>,
Kenny Tilton <·······@nyc.rr.com> wrote:
> AllegroCL:
> (package-nicknames (find-package :keyword)) => ("")
>
> Lispworks:
> (package-nicknames (find-package :keyword)) => nil
>
> Whassup with ACL? Any rationale for that?
It simplifies parsing keywords. Given a token like :FOO, it splits it
into the parts before and after the colon, which are "" and "FOO"
respectively. Then it does (find-package <part-before>), which expects
it to be the name or nickname of a package. Giving the keyword package
a nickname of "" means that it doesn't have to be treated as a special
case by the parser.
--
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Barry Margolin wrote:
> In article <·····················@twister.nyc.rr.com>,
> Kenny Tilton <·······@nyc.rr.com> wrote:
>
>
>>AllegroCL:
>>(package-nicknames (find-package :keyword)) => ("")
>>
>>Lispworks:
>>(package-nicknames (find-package :keyword)) => nil
>>
>>Whassup with ACL? Any rationale for that?
>
>
> It simplifies parsing keywords. Given a token like :FOO, it splits it
> into the parts before and after the colon, which are "" and "FOO"
> respectively. Then it does (find-package <part-before>), which expects
> it to be the name or nickname of a package. Giving the keyword package
> a nickname of "" means that it doesn't have to be treated as a special
> case by the parser.
>
thx for the explanation. yecch. i hate that kind of cutesy code. case in
point: while ripping off the ACL apropos dialog I had code to display
the package of a symbol:
(or (car (package-nicknames pkg))
(package-name pkg))
looks good, right? nope. for any keyword, => ""
kt
--
Home? http://tilton-technology.com
Cells? http://www.common-lisp.net/project/cells/
Cello? http://www.common-lisp.net/project/cello/
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
Your Project Here! http://alu.cliki.net/Industry%20Application
* Kenny Tilton <·······@nyc.rr.com>:
> thx for the explanation. yecch. i hate that kind of cutesy code. case in
> point: while ripping off the ACL apropos dialog I had code to display the
> package of a symbol:
>
> (or (car (package-nicknames pkg))
> (package-name pkg))
>
> looks good, right? nope. for any keyword, => ""
Assuming that the above code is hoping to pick the smallest name for a
package (mostly 'cos I had exactly the same code in a couple of CL init
files for displaying a nice-ish prompt in the REPL) then it's probably nice
until you meet a package where the car of the nicknames is longer than the
package name or any of the other nicknames.
I ended up sorting the lot (name and nicknames) on length and picking the
shortest. While it's not perfect that might at least give you the point
where you can filter out empty nicknames.
--
Dave Pearson
http://www.davep.org/lisp/
Barry Margolin <······@alum.mit.edu> writes:
> In article <·····················@twister.nyc.rr.com>,
> Kenny Tilton <·······@nyc.rr.com> wrote:
>
>> Whassup with ACL? Any rationale for that?
>
> It simplifies parsing keywords. Given a token like :FOO, it splits it
> into the parts before and after the colon, which are "" and "FOO"
> respectively. Then it does (find-package <part-before>), which expects
> it to be the name or nickname of a package. Giving the keyword package
> a nickname of "" means that it doesn't have to be treated as a special
> case by the parser.
But it also changes the parse of tokens like ||:FOO, which I think
it's harder to argue that intentional.
CHristophe
--
http://www-jcsu.jesus.cam.ac.uk/~csr21/ +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%") (pprint #36rJesusCollegeCambridge)
Christophe Rhodes <·····@cam.ac.uk> wrote:
+---------------
| Barry Margolin <······@alum.mit.edu> writes:
| > Kenny Tilton <·······@nyc.rr.com> wrote:
| >> Whassup with ACL? Any rationale for that?
| >
| > It simplifies parsing keywords. Given a token like :FOO, it splits it
| > into the parts before and after the colon, which are "" and "FOO"
| > respectively. Then it does (find-package <part-before>), which expects
| > it to be the name or nickname of a package. Giving the keyword package
| > a nickname of "" means that it doesn't have to be treated as a special
| > case by the parser.
|
| But it also changes the parse of tokens like ||:FOO, which I think
| it's harder to argue that intentional.
+---------------
Note that CMUCL-18e behaves like ACL in this regard:
> (find-package nil)
NIL
> (find-package "")
#<The KEYWORD package, 0/2 internal, 1701/2061 external>
> (package-nicknames *)
("")
> '||:FOO
:FOO
> (symbol-package '||:FOO)
#<The KEYWORD package, 0/2 internal, 1702/2061 external>
>
-Rob
-----
Rob Warnock <····@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607