This repository has been archived by the owner on Dec 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
128 lines (92 loc) · 5.47 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
E X T E N S I B L E
|#%#&&. |##&%&# |#\ /|# /#\ ,&#%#&. ,&##%#&.
|# |# |# |#&\/&|# /%:#\ |# |#
|# |# |##&%&# |# |# |# |# |# `+&#%#+,
|# |# |# |# |# |####|# |# |#
|#$$$|# |##&%&# |# |# |# |# `+#%#&#~ ~&#%&#^
D E F I N E R M A C R O S
Demacs is an extensible Common Lisp utility software to ease the definitions in
language by supplying a standard syntax. Demacs is written from scratch with the
idea of syntax of cl-def[1] in mind. Despite there are some other definer
utilities in the wide (e.g. definer[2], cl-def[1]), almost all of them lack of
at least one of below functionalities.
- Extensibility. (definer[2] doesn't support extensions.)
- Affordable dependency. (cl-def[1] depends on some libraries, and those
libraries depend on some other libraries and so on... You're required to
install a dozen of libraries to benefit from a single definer utility.
Furthermore, a major portion of related libraries are not available via
ASDF-INSTALL.)
To summarize, demacs is implemented with KISS[3] principle in mind. And as a
bonus, demacs has no library dependencies.
[1] http://common-lisp.net/project/cl-def/
[2] http://www.common-lisp.net/project/definer
[3] http://en.wikipedia.org/wiki/KISS_principle
--- S Y N T A X ---
(def function-spec name lambda-list [[declaration* | documentation]] form*)
function-spec ::= function | (function {function-option}*)
function-option ::= i | o | d | e
(def macro-spec name macro-lambda-list [[declaration* | documentation]] form*)
macro-spec ::= macro | (macro {macro-option}*)
macro-option ::= o | d | e
(def compiler-macro-spec name macro-lambda-list [[declaration* | documentation]] form*)
compiler-macro-spec ::= compiler-macro | (compiler-macro {macro-option*})
(def generic-spec name gf-lambda-list [[{method-description}*]])
generic-spec ::= generic | (generic {generic-option}* [[gf-option*]])
generic-option ::= o | d | e
(def method-spec name specialized-lambda-list [[declaration* | documentation]] form*)
method-spec ::= method | (method {method-option}* [[method-qualifier*]])
method-option ::= o | d
(def (type-spec) name deftype-lambda-list [[declaration* | documentation]] form*)
type-spec ::= type | (type {type-option}*)
type-option ::= e
(def print-object-spec object (self stream) [[declaration* | documentation]] form*)
print-object-spec ::= print-object | (print-object &key print-identity print-type package)
(def setf-spec name defsetf-lambda-list (new-value) [[declaration* | documentation]] form*)
setf-spec ::= setf | (setf {setf-option}*)
setf-option ::= o | d
(def constant-spec name value)
constant-spec ::= constant | (constant {variable-option}* &key test documentation)
variable-option := e
(def special-variable-spec name [value])
special-variable-spec ::= special-variable | (special-variable {variable-option}* &key documentation)
(def symbol-macro-spec name form)
symbol-macro-spec ::= symbol-macro | (symbol-macro {variable-option}*)
(def class-spec name ({superclass}*) ({slot-specifier}*) [[class-option]])
class-spec ::= class | (class {class-option}* &key initarg-format accessor-format reader-format writer-format)
class-option ::= e | a | s | n | c | r | w | m
(def condition-spec name (parent-type*) ({slot-spec}*) option*)
condition-spec ::= condition | (condition {class-option}* &key initarg-format accessor-format reader-format writer-format)
(def struct-spec name-and-options [documentation] {slot-description}*)
name-and-options ::= structure-name | (structure-name [[options]])
struct-spec ::= struct | (struct {class-option}*)
i -- Inline function.
o -- Make optimization declarations.
d -- Make debugging declarations.
e -- Export function.
a -- Export class accessors.
s -- Export slot symbols.
n -- Introduce :INITARG keywords into slot specifiers.
c -- Introduce :ACCESSOR keywords into slot specifiers.
r -- Introduce :READER keywords into slot specifiers.
w -- Introduce :WRITER keywords into slot specifiers.
m -- Make a MAKE-FOO function according to the class. (Exported if class is also
requested to be exported.)
--- E X T E N S I B I L I T Y ---
All definers in demacs first inherits DEFINER class. And based on DEFINER class,
INITIALIZE-DEFINER and EXPAND-DEFINER gets called. Used CLOS architecture, helps
programmers to benefit from inherited classes methods and eases implementation
of definers. For instance, consider macro definer:
(defclass macro-definer (function-definer) ())
(defmethod available-definer-options ((definer macro-definer))
(list #\o #\d #\e))
(defmethod expand-definer ((definer macro-definer))
(expand-function-like-definer definer 'defmacro))
There are various helper functions served with the package to ease the
implementation of new definers. Decide which file fits better to your new
definer -- Will it have a function-like, variable-like or miscelanous form? --
and check the existing samples in the existing file.
--- I N D E N T A T I O N ---
Because of definer macros don't play well with the existing lisp indentation
semantics of editors, it can sometimes become a pain to indent definer forms in
an appropriate style. To solve this problem, see indentation scripts supplied
under contrib directory.