3 ms·
The CL package system allows local aliases. How do you think you can be in the default cl-user package yet refer to cl:cons as just cons? Firstly, the exported
by kazinator 10y ago
The CL package system allows local aliases. How do you think you can be in the default cl-user package yet refer to cl:cons as just cons?
Firstly, the exported symbols in one package can be made visible in another package through package use. Secondly, a symbol from package A can actually be made present in package B via import: http://clhs.lisp.se/Body/f_import.htm http://clhs.lisp.se/Body/f_import.htm
- junke 10y agoRegarding packages, sometimes I wonder whether package names could have been symbols: that would allow for gensymed packages, as well as hierarchical packages.
- kazinator 10y agoI implemented a package system influenced by CL's. I thought of the idea of package names themselves being symbols (themselves interned in some root package that has no name, or perhaps has one of those symbols as its name). I couldn't come up with a good set of requirements that would make things better, so I didn't bother with it. It just seemed like self-refererence for the sake of self-reference, like some new appendix to D. Hofstadter's GEB. :)
- aidenn0 10y agoI prototyped a reader-macro for CL that does this, specifically because it gives you package-local nicknames: https://github.com/jasom/spm-reader https://github.com/jasom/spm-reader
- kazinator 10y agoI once made a kind of "package Swiss Army Knife" reader macro for Common Lisp which lets you do cool things. It's reasonably well documented in a header comment. It might be up your alley, since you're working on a package-related reader macro: http://www.kylheku.com/cgit/lisp-snippets/tree/pkg.lisp http://www.kylheku.com/cgit/lisp-snippets/tree/pkg.lisp
- cronjobber 10y agoThe context was: "FOO can be generic and applied to different types of objects." That only works if everybody uses the same symbol FOO. Library:FOO is a different symbol and won't be combined automatically, so you must package-qualify. (Regarding local aliases, I was talking about local package name aliases, which could make it somewhat less awkward.)
- kazinator 10y agoOf course. Why would LOTTERY:DRAW and GRAPHICS:DRAW be smashed together?
- aidenn0 10y agobut now you're back to (lottery:draw x) which isn't any shorter than (lottery-draw x), so the point about names not being namespaced to the object they are applied to remains.
- kazinator 10y agoIf I have inherited both, I cannot use the symbol DRAW to refer to both; at most one of them can be just DRAW.