Make the Common Lisp reader aware of packages
This enhances the Common Lisp reader so that symbols are interned in the current package. Also makes the reader recognize the colon in FOO:BAR as package prefix marker.
To ease the transition from Scheme to CL we have the auxiliary "KAWA" package. Symbols in that package are of type SimpleSymbol. Some of the existing code, eg. rewriteBody in Lisp2Compilation, only works with SimpleSymbols. As I didn't want to touch that code, I changed the testsuite instead by prefixing the problematic symbols with "KAWA:" as in: (lambda (x) (KAWA:declare (KAWA:type KAWA:symbol x)) x)
Maybe the code in Lisp2Compilation can be replaced with something based on define-rewrite-syntax, which I suppose would be much more concise and I hope will automatically use the right symbols.
I also added some package related functions to primitives.lisp for easier testing.
- gnu/commonlisp/lang/CommonLisp.java (CLReadTable): New CL specific readtable. The package aware interning is done by overriding makeSymbol. For the time beeing, the very approximate handling of ':' is also done in makeSymbol .
(createReadTable): Override it and use the new readtable.
gnu/kawa/lispexpr/LispPackage.java (makeUninternedSymbol): New helper that ensures that we create SimpleSymbols resp. Keywords for the KAWA resp. KEYWORD package. (lookup): Fix a bug. The previous code would go into an endless recursion when it had to search inherited symbols. (keywordp, symbolPackage, intern, findPackage): New. Java part of the implementation for the corresponding CL functions. LispPackage seemed like the right place for this code.
gnu/commonlisp/lisp/primitives.lisp (keywordp, symbol-package, find-package, intern, packagep): New. Implementation of the CL functions, at least partial. (%to-package, %to-string): New helpers.
gnu/commonlisp/testsuite/lang-test.lisp: Add tests for FOO:BAR syntax, intern, keywordp etc.
gnu/commonlisp/testsuite/lambda.lisp: Add KAWA: prefix where necessary.
gnu/commonlisp/testsuite/warnings.lisp: Change to new expected output, which includes namespace.