Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the advanced-readtable Reference Manual, version 1.0.1, generated automatically by Declt version 3.0 "Montgomery Scott" on Mon Apr 19 14:00:31 2021 GMT+0.
• Introduction | What advanced-readtable is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
Features
Either use named-readtables and write
(in-readtable :advanced)
or simply add to advanced-readtable to current readtable
(advanced-readtable:!)
If you want also to substitute cl:defpackage, cl:in-package, cl:find-package and cl:find-symbol by there adbanced versions, use (advanced-readtable:!!) or (in-readtable :advanced) and (advanced-readtable:activate-cl-substitutes).
Append contents of init.el to the end of your ~/.emacs file.
Then, when you start slime, advanced-readtable will be loaded and used by slime. So you will have all completions for hierarchy packages, local-nicknames, aliases, ...
Note: in REPL you will have advanced-readtable instead of the standard readtable.
Advanced-readtable has fully functional built-in support of hierarchy-packages. .name means "subpackage name in current package", ..name -- "subpackage name in above package", ...name -- "subpackage in two-level-up package" and so on. In in-package you may use .. for above package, ... for two level up, and so on. Verbose documentation one may see at allegro CL.
CL-USER> (defpackage .test (:use cl)))
#<PACKAGE "COMMON-LISP-USER.TEST">
CL-USER> (in-package .test)
TEST> (in-package ..)
CL-USER> (defpackage .test.a (:use cl))
#<PACKAGE "COMMON-LISP-USER.TEST.A">
CL-USER> (in-package .test.a)
A> '...::car
CAR
A> (eq '...::car 'cl:car)
T
A> (in-package ...test)
TEST> (in-package ..)
CL-USER>
You may use local-nicknames in defpackage (syntax taken from SBCL)
CL-USER> (defpackage :foo (:use :cl) (:local-nicknames (:it :cl)))
CL-USER> (in-package :foo)
FOO> (it:car '(1 2 3))
1
For example, you have packages com.clearly-useful.iterator-protocol, com.clearly-useful.reducers, ... You may use them as
(push-import-prefix :com.clearly-useful)
(iterator-protocol:do-iterator ...)
(reducers:r/map #'1+ data)
and so on. Package prefix is enabled per package so it is safe to use it in your package.
If there is package, which name coincides with shortcut, package name has priority.
So, if you make
(defpackage :reducers ...)
after that reducers:... will refer to new package, not com.clearly-useful.reducers.
Enables package nickname in CURRENT-PACKAGE. For example, you found COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LIST package and want to use it. But don't want to USE-PACKAGE them, because some exported symbols from it are clashing with yours.
You may do it right:
(push-local-nickname :com.informatimago.common-lisp.cesarum.list :ilist)
(ilist:circular-length l)
Local-nicknames are local, so you may use it freely.
If package A wants package LIB version 1, and package B wants package LIB version 2, one can simply rename LIB version 1 to LIB1 and LIB version 2 to LIB2 and make
(push-local-nickname :lib1 :lib :a)
(push-local-nickname :lib2 :lib :b)
This command also adds local subpackage alias. In the previous example a.lib and b.lib will be aliases to lib1 and lib2. If there is a real package with such name, alias will be shadowed, so don't worry too much about it.
Many macroses use there own clauses. For example, ITERATE uses FOR, COLLECT and so on. If you don't want to USE-PACKAGE iterate, this function will help.
(push-local-package 'iter:iter :iterate)
(iter:iter (for i from 1 to 10) (collect i))
Caution: this function enables package substitution in all cases, where SYMBOL is the car of a list. For example, this will be error:
(let (iter:iter for) (list iter:iter for))
, because first for is in ITERATE package, but second -- is not.
Be careful: this change is not local to your package.
FUNC will get stream of reader and the symbol (see set-macro-character).
To prevent symbol from processing (for example in set-macro-symbol construction) you should enclose it in bars.
This construction will set 'foo as an alias to 'long-package-name:long-name:
(set-macro-symbol '|FOO|
(lambda (stream symbol)
(declare (ignore stream symbol))
'long-package-name:long-name))
Another way to prevent symbol processing is setting advanced-readtable:*enable-symbol-readmacro*
to nil.
Remember, that symbol processing is done during reading the file, so, if you need to temporarily disable
*enable-symbol-readmacro*
, then enclose it in #.
Now you may make something like
html:[body [table (as-html sql:[select * from t1])]]
html:[ and sql:[ will have different handlers and you may mix them in one expression.
Moreover, you may alias variables from other packages and set them through alias. But be careful: this change is not local to your package. If you write qualified name of the symbol, you should enclose package-name in bars:
(set-macro-symbol '|OTHER-PACKAGE|:foo
(lambda (stream symbol)
(declare (ignore stream symbol))
'long-package-name:long-name))
Returns function, assigned by set-macro-symbol
There are five lists:
*package-finders*
-- global for find-package*symbol-finders*
-- global for find-symbolThey are all alists. Key denotes handler and should be uniq for the list. Value should have form (lambda (name package) ...) and return symbol for symbol-finders and extra-finders and return pacakge for package-finders.
You may freely change them to develop your own symbol or package schemes (for example, hierarchy-packages, conduits and so on).
To simplify adding new handlers with keys there is macro set-handler
(set-handler (package-finders pack) '(:my handler1) #'handler-func)
will set handler for package pack, if there are no hanler with key (:my handler1). So you may set it in your file and not be afraid, that it will duplicate on reloading.
You must only ASCII characters for first letter of every part of package name and for first letter of symbols, that you want to use in set-macro-symbol
If you really need other characters you may set them by calling
(set-macro-character c #'advanced-readtable:read-token-with-colons t)
for every your character.
If you need to temporary disable macro-characted substitution, you may set
advanced-readtable:*enable-symbol-readmacro*
to nil. It could be useful, if you
describe a lot of symbols and don't want to enclose every of them in || (and upcase, of course).
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The advanced-readtable system |
Roman Klochkov <kalimehtar@mail.ru>
BSD
Advanced customizable readtable
1.0.1
named-readtables
advanced-readtable.asd (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
Next: The advanced-readtable/package․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
advanced-readtable.asd
advanced-readtable (system)
Next: The advanced-readtable/finders․lisp file, Previous: The advanced-readtable․asd file, Up: Lisp files [Contents][Index]
advanced-readtable (system)
package.lisp
Next: The advanced-readtable/api․lisp file, Previous: The advanced-readtable/package․lisp file, Up: Lisp files [Contents][Index]
package.lisp (file)
advanced-readtable (system)
finders.lisp
Next: The advanced-readtable/readtable․lisp file, Previous: The advanced-readtable/finders․lisp file, Up: Lisp files [Contents][Index]
finders.lisp (file)
advanced-readtable (system)
api.lisp
Next: The advanced-readtable/hierarchy․lisp file, Previous: The advanced-readtable/api․lisp file, Up: Lisp files [Contents][Index]
api.lisp (file)
advanced-readtable (system)
readtable.lisp
Previous: The advanced-readtable/readtable․lisp file, Up: Lisp files [Contents][Index]
readtable.lisp (file)
advanced-readtable (system)
hierarchy.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The advanced-readtable package | ||
• The advanced-readtable.junk package |
Next: The advanced-readtable․junk package, Previous: Packages, Up: Packages [Contents][Index]
package.lisp (file)
Previous: The advanced-readtable package, Up: Packages [Contents][Index]
readtable.lisp (file)
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported special variables | ||
• Exported macros | ||
• Exported functions |
Next: Exported macros, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
Enables processing of symbol-readmacro.
readtable.lisp (file)
Hash symbol -> alist (key . symbol-handler)
Used for PUSH-LOCAL-PACKAGE. It will be searched before CL:FIND-SYMBOL.
Will be checked inside list, where car of list eq SYMBOL.
finders.lisp (file)
Alist (equal key . package-handler). Contains global handlers for FIND-PACKAGE.
finders.lisp (file)
Alist (equal key . symbol-handler). Contains global handlers for FIND-SYMBOL.
finders.lisp (file)
Next: Exported functions, Previous: Exported special variables, Up: Exported definitions [Contents][Index]
hierarchy.lisp (file)
hierarchy.lisp (file)
This is middle-level public API for changing handlers for
find-symbol and find-package. There are five lists:
*package-finders* – global for find-package
*symbol-finders* – global for find-symbol
(package-finders package) – per-package for find-package
(symbol-finders package) – per-package for find-symbol
(extra-finders symbol) – per-symbol for (symbol ....) package substitution
Key should be uniq in the sense of EQUAL in the list. SET-HANDLER adds new handler if it is not already there.
finders.lisp (file)
Previous: Exported macros, Up: Exported definitions [Contents][Index]
readtable.lisp (file)
hierarchy.lisp (file)
readtable.lisp (file)
hierarchy.lisp (file)
We try to find package.
1. By full name with CL:FIND-PACKAGE.
2. By per-package handlers. Here we wil try local-nicknames and so on.
3. By global handlers. Here we may use, for example, hierarchical packages.
finders.lisp (file)
We try to find symbol
1. In package set with car of list, for example, PUSH-LOCAL-PACKAGE
2. By CL:FIND-SYMBOL, when package explicitly given
3. By packages added with package:(...)
4. By per-package finders
5. By global finders
6. By CL:FIND-SYMBOL
finders.lisp (file)
Syntax is like get-macro-character. Returns function, assigned by set-macro-symbol
finders.lisp (file)
Returns alist (key . package-handler) for package
finders.lisp (file)
(setf package-finders) (function)
Sets alist (key . package-handler) for package
finders.lisp (file)
package-finders (function)
Enables using package name omitting prefix.
For example, you have packages com.clearly-useful.iterator-protocol, com.clearly-useful.reducers, ...
You may use them as
(push-import-prefix :com.clearly-useful)
(iterator-protocol:do-iterator ...)
(reducers:r/map #’1+ data)
and so on.
Package prefix is enabled per package so it is safe to use it in your package.
If there is package, which name coincides with shortcut, package name has priority.
So, if you make
(defpackage :reducers ...)
after that reducers:... will refer to new package, not com.clearly-useful.reducers.
api.lisp (file)
Enables package nickname in CURRENT-PACKAGE.
For example, you found COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LIST package and want to use
it. But don’t want to USE-PACKAGE them, because some exported symbols from it are clashing
with yours.
You may do it right:
(push-local-nickname :com.informatimago.common-lisp.cesarum.list :ilist)
(ilist:circular-length l)
Local-nicknames are local, so you may use it freely.
If package A wants package LIB version 1, and package B wants package
LIB version 2, one can simply rename LIB version 1 to LIB1 and rename LIB
version 2 to LIB2 and make
(push-local-nickname :lib1 :lib :a)
(push-local-nickname :lib2 :lib :b)
If enabled global-nicknames via enable-global-nicknames,
then also created alias in current package.
For example,
(push-local-nickname :lib1 :lib :a), states, that package A.LIB is eq to LIB1.
api.lisp (file)
Sets local-package for a symbol. Many macroses use there own clauses.
For example, ITERATE uses FOR, COLLECT and so on.
If you don’t want to USE-PACKAGE iterate, this function will help.
(push-local-package ’iter:iter :iterate)
(iter:iter (for i from 1 to 10) (collect i))
Caution: this function enables package substitution in all cases,
where SYMBOL is the car of a list.
For example, this will be error:
(let (iter:iter for) (list iter:iter for))
, because first for is in ITERATE package, but second – is not.
api.lisp (file)
Reads token, then analize package part if needed
readtable.lisp (file)
Syntax is like set-macro-character,
except that FUNC is binded to SYMBOL, not character
finders.lisp (file)
Returns alist (key . symbol-handler) for package
finders.lisp (file)
(setf symbol-finders) (function)
Sets alist (key . symbol-handler) for package
finders.lisp (file)
symbol-finders (function)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal special variables | ||
• Internal macros | ||
• Internal functions | ||
• Internal types |
Next: Internal macros, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
Boolean: iff reader in list and car is not read
readtable.lisp (file)
Support readtable with colon as whitespace
readtable.lisp (file)
Alist (key . symbol-handler). Used in PUSH-LOCAL-PACKAGE processing
finders.lisp (file)
Package aliases. Hash nickname: string -> package
api.lisp (file)
Hash package -> alist (key . package-handler). Contains per-package handlers for FIND-PACKAGE.
finders.lisp (file)
List of packages: for pack:( ... pack2:(...))
finders.lisp (file)
Hash package -> alist (equal key . symbol-handler). Contains per-package handlers for FIND-SYMBOL.
finders.lisp (file)
Hash symbol -> macro-symbol-handler Contans handlers for macro-symbols.
finders.lisp (file)
Fill this, if you need extra characters for packages to begin with
readtable.lisp (file)
Next: Internal functions, Previous: Internal special variables, Up: Internal definitions [Contents][Index]
Local macros for push-* functions. No gensyms intended.
api.lisp (file)
readtable.lisp (file)
Next: Internal types, Previous: Internal macros, Up: Internal definitions [Contents][Index]
readtable.lisp (file)
readtable.lisp (file)
hierarchy.lisp (file)
DO: Reads colons from STREAM RETURN: number of the colons
readtable.lisp (file)
readtable.lisp (file)
Returns alist (key . symbol-handler) for symbol
finders.lisp (file)
(setf extra-finders) (function)
Sets alist (key . symbol-handler) for symbol
finders.lisp (file)
extra-finders (function)
finders.lisp (file)
HANDLERS-LIST – alist (key . package-handler).
The function calls handlers until one of them returns not null.
Then the result of last call is returned
finders.lisp (file)
HANDLERS-LIST – alist (key . package-handler).
The function calls handlers until one of them returns not null.
Then the result of last call is returned
finders.lisp (file)
hierarchy.lisp (file)
If C is macro-char, return GET-MACRO-CHARACTER
readtable.lisp (file)
readtable.lisp (file)
Returns nil if already normalized.
Replace first section of hierarchy with proper name
hierarchy.lisp (file)
readtable.lisp (file)
hierarchy.lisp (file)
readtable.lisp (file)
Read symbol package:sym or list package:(...)
readtable.lisp (file)
DO: Reads from STREAM a symbol or number up to whitespace or colon RETURN: symbols name or numbers value
readtable.lisp (file)
readtable.lisp (file)
hierarchy.lisp (file)
readtable.lisp (file)
readtable.lisp (file)
Previous: Internal functions, Up: Internal definitions [Contents][Index]
Handler for SET/GET-MACRO-SYMBOL
finders.lisp (file)
Argument of CL:FIND-PACKAGE
finders.lisp (file)
Type of handlers for package finding.
First arg is a name to find. Second – current package
finders.lisp (file)
Type of handlers for symbol finding
First arg is a name to find. Second – current package
finders.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | A F L |
---|
Jump to: | A F L |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | !
%
(
A C D E F G H I M N O P R S T W |
---|
Jump to: | !
%
(
A C D E F G H I M N O P R S T W |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
+
S |
---|
Jump to: | *
+
S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | A M P S T |
---|
Jump to: | A M P S T |
---|