Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the reader Reference Manual, version 0.10.0, generated automatically by Declt version 3.0 "Montgomery Scott" on Sun May 15 06:00:01 2022 GMT+0.
• Introduction | What reader 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 |
Download from the Releases section.
I'll promote v0.10.0 to v1.0.0 if there are no significant changes over the next year.
(reader:enable-reader-syntax &rest reader-macro-identifiers)
;; OR
(reader+swank:enable-package-local-reader-syntax &rest reader-macro-identifiers)
;; (describe 'reader:enable-reader-syntax) ; for a list of identifiers
;; Complementory macros
;; (reader:disable-reader-syntax) ; is complementary
;; OR
;; (reader+swank-disable-package-local-reader-syntax)
CL-USER> #[[1 2 3
4 5 6]
[3 2 1
7 8 9]]
#3A(((1 2 3) (4 5 6)) ((3 2 1) (7 8 9))) ; cleaner syntax for arrays
CL-USER> (gethash 'a {eq 'a 1 'b 2}) ; hash-tables
1
T
CL-USER> (hash-set:hs-memberp #{"a" "b" "c"} "c") ; hash-set - can change in future
T
CL-USER> [#2A((1 2 3) (4 5 6)) 1 0] ; accessors
4
CL-USER> (setf reader:*get-val-array-function* 'select:select)
SLCT:SELECT
CL-USER> (let ((arr #2A((1 2 3) (4 5 6))))
[arr t 0])
#(1 4)
CL-USER> [{"a" 1 "b" 2} "a"]
1
T
CL-USER> [(cl-json:decode-json-from-string "{\"a\":1, \"b\":2}") :b] ; works with alists
2
CL-USER> (-> {"a" "apple" "b" "ball"} ["b"] [1]); accessors can be chained using arrows:->
#\a
CL-USER> #!echo -n hello world
hello world ; Captures until the end of line
NIL ; Should be possible to capture into a string
NIL ; but not ideal for speed
0
CL-USER> (let ((a t)) !a) ; not
NIL
CL-USER> (let ((a 5.0d0)) $a) ; write-to-string
"5.0d0" ; should this be "ensure-string"? raise an issue!
CL-USER> ?reader:enable-reader-syntax ; variable use not intended
READER:ENABLE-READER-SYNTAX
[symbol]
ENABLE-READER-SYNTAX names a macro:
Lambda-list: (&REST READER::READER-MACRO-IDENTIFIERS)
Documentation:
READER-MACRO-IDENTIFIERS are any of the following symbols:
GET-VAL, HASH-TABLE, NOT, STRING, DESCRIBE, ARRAY, SET, RUN-PROGRAM
Source file: /home/user/quicklisp/local-projects/reader/reader.lisp
The functions used for constructing arrays, hash-tables, sets, accessing array elements or accessors in general can be specified by
*array-function*
*hash-table-function*
*set-function*
*get-val-array-function*
*get-val-function*
This should allow users to use fset or access or other libraries for the respective functions.
By default, alists and plists are treated distinct from lists whenever possible (see the get-val
method specialized on lists). To disable this behavior, set each of these to T
:
*alists-are-lists*
*plists-are-lists*
{"a" 1 "b" 2}
- hash tables use 'equalp
as the default test. The intended test function can be specified as the first element of the literal syntax. Besides providing with a choice, this also gets the indentation correct (see Modification for emacs.(setf [] ...)
does not work with empty alists and plists. This seems to require setf-expanders with get-val
generic-function.[...]
(get-val
) does not work inside #[...]
(array
) syntax. I do not have a plan or haven't figured out how to combine the two; and I find that okay since the array
syntax is meant for cleaner representation in works involving matrices.lambda
with the following usage has been removed.CL-USER> (mapcar λ(write-to-string -) '(2 3 4)) ; lambdas
("2" "3" "4")
This begins to feel like line-noise after a while and is not ideal for readability; a better equivalent is the simple macro
CL-USER> (defmacro lm (&rest var-body)
`(lambda ,(butlast var-body)
,@(last var-body)))
LM
CL-USER> (mapcar (lm o (write-to-string o)) '(2 3 4))
("2" "3" "4")
Since the function used for constructing hash-tables is now configurable (via reader:*hash-table-function*
), the first input to the hash-table may be interpreted as the equality function. Thus, hash-table syntax can take an even (with default test cl:equalp
) or odd (with the first symbol being interpreted as the equality function) number of arguments.
Now works for non-empty lists.
(ql:quickload "reader")
(5am:run :reader)
;; OR
(asdf:test-system "reader")
(modify-syntax-entry ?\[ "(]" lisp-mode-syntax-table)
(modify-syntax-entry ?\] ")[" lisp-mode-syntax-table)
(modify-syntax-entry ?\{ "(}" lisp-mode-syntax-table)
(modify-syntax-entry ?\} "){" lisp-mode-syntax-table)
(define-key paredit-mode-map (kbd "{") 'paredit-open-curly)
(define-key paredit-mode-map (kbd "}") 'paredit-close-curly)
(global-set-key (kbd "C-S-l") (lambda () ; for inserting lambda
(interactive)
(insert-char (aref (symbol-name 'λ) 0))))
(setq paredit-space-for-delimiter-predicates
(list (lambda (endp delimiter)
(not (and (eql ?\( delimiter)
(member (char-before (point))
'(?\@ ?λ))))))))
(set-language-environment "UTF-8")
Motivation: paredit curly brace matching in swank-clojure repl - Stack OverFlow
Known issues include aligning hash-tables without first-element-as-key:
{"hello" 1
"world" 2}
A work-around is to specify the test as the first element, and let that default exist for one-liners:
{equal "hello" 1
"world" 2}
{"hello" 1 "world" 2}
cl-interpol
is a prominent library providing perl / shell-like string interpolation facilities.cl-json
can be used for parsing JSONext: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The reader system |
MIT
A utility library intended at providing configurable reader macros for
common tasks such as accessors, hash-tables, sets, uiop:run-program, arrays and a few others.
0.10.0
reader.asd (file)
reader.lisp (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The reader.asd file | ||
• The reader/reader.lisp file |
Next: The reader/reader․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
reader.asd
reader (system)
Previous: The reader․asd file, Up: Lisp files [Contents][Index]
reader (system)
reader.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The reader package |
reader.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 generic functions |
Next: Exported macros, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
If T, ALISTS will not be treated specially by READER:GET-VAL method for lists.
reader.lisp (file)
A symbol bound (at read-time) to a function that takes INITIAL-CONTENTS
as its argument and returns the array. INITIAL-CONTENTS is a list of nested-lists.
reader.lisp (file)
A symbol bound (at read-time) to a function that takes
(ARRAY &REST SUBSCRIPTS)
as arguments and returns the corresponding value.
This is assumed to have a SETF defined.
This variable is significant if READER:*GET-VAL-FUNCTION* is bound to READER:GET-VAL.
reader.lisp (file)
A symbol bound (at read-time) to a function that takes
(OBJECT &REST KEY/S)
as arguments and returns the value corresponding to the KEY/S.
reader.lisp (file)
A symbol bound (at read-time) to a function that takes
(PLIST &KEY TEST)
as arguments and returns the hash-table.
reader.lisp (file)
If T, PLISTS will not be treated specially by READER:GET-VAL method for lists.
reader.lisp (file)
A symbol bound (at read-time) to a function that takes
(LIST &KEY TEST)
as arguments and returns the set.
reader.lisp (file)
Next: Exported generic functions, Previous: Exported special variables, Up: Exported definitions [Contents][Index]
reader.lisp (file)
READER-MACRO-IDENTIFIERS are any of the following symbols: GET-VAL, HASH-TABLE, NOT, STRING, DESCRIBE, ARRAY, SET, RUN-PROGRAM
reader.lisp (file)
Previous: Exported macros, Up: Exported definitions [Contents][Index]
reader.lisp (file)
(setf get-val) (generic function)
get-val (generic function)
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal constants | ||
• Internal special variables | ||
• Internal macros | ||
• Internal functions |
Next: Internal special variables, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
reader.lisp (file)
Next: Internal macros, Previous: Internal constants, Up: Internal definitions [Contents][Index]
reader.lisp (file)
reader.lisp (file)
Next: Internal functions, Previous: Internal special variables, Up: Internal definitions [Contents][Index]
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
This macro is only made for use by read-and-eval functionality, and rather directed towards tests than users. So, do not export.
reader.lisp (file)
Previous: Internal macros, Up: Internal definitions [Contents][Index]
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
reader.lisp (file)
reader.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: | F L R |
---|
Jump to: | F L R |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | %
(
A D E F G H L M N R S W |
---|
Jump to: | %
(
A D E F G H L M N R S W |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
+
C S |
---|
Jump to: | *
+
C S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | P R S |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
P | |||
Package, reader : | The reader package | ||
| |||
R | |||
reader : | The reader system | ||
reader : | The reader package | ||
| |||
S | |||
System, reader : | The reader system | ||
|
Jump to: | P R S |
---|