Skip to content
This repository was archived by the owner on Mar 23, 2021. It is now read-only.

Commit 57df513

Browse files
committed
Changed README from org-mode to markdown
1 parent 926f9f3 commit 57df513

File tree

2 files changed

+68
-62
lines changed

2 files changed

+68
-62
lines changed

README.org renamed to README.md

Lines changed: 67 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1-
* defclass-std
2-
[[https://travis-ci.org/EuAndreh/defclass-std][https://travis-ci.org/EuAndreh/defclass-std.svg?branch=master]]
3-
[[https://coveralls.io/r/EuAndreh/defclass-std][https://coveralls.io/repos/EuAndreh/defclass-std/badge.svg?branch=master]]
1+
defclass-std
2+
============
43

5-
Most times, when sketching out a new class, I often commit lots of typos and forget to add an =:initform=.
4+
[![Build Status](https://travis-ci.org/EuAndreh/defclass-std.svg?branch=master)](https://travis-ci.org/EuAndreh/defclass-std)
5+
[![Coverage Status](https://coveralls.io/repos/EuAndreh/defclass-std/badge.svg?branch=master)](https://coveralls.io/r/EuAndreh/defclass-std?branch=master)
66

7-
Also, the throw away class designed in the beginning may thrive and stay the same. If only there was a way to overcome these problems... There is!
7+
Most times, when sketching out a new class, I often commit lots of typos and forget to add an `:initform`.
88

9-
This simple macro atempts to give a very DRY and succint interface to the common =DEFCLASS= form. The goal is to offer most of the capabilities of a normal =DEFCLASS=, only in a more compact way.
9+
Also, the throw away class designed in the beginning may thrive and stay the same. If only there was a way to overcome these problems... There is!
1010

11-
Everything compiles down to =DEFCLASS=.
12-
** Usage
13-
#+BEGIN_SRC lisp
11+
This simple macro atempts to give a very DRY and succint interface to the common `DEFCLASS` form. The goal is to offer most of the capabilities of a normal `DEFCLASS`, only in a more compact way.
12+
13+
Everything compiles down to `DEFCLASS`.
14+
15+
Usage
16+
-----
17+
18+
```lisp
1419
* (ql:quickload :defclass-std)
1520
; => (:DEFCLASS-STD)
1621
* (import 'defclass-std:defclass/std)
1722
; => T
18-
#+END_SRC
23+
```
1924

20-
A simple class defined with =DEFCLASS/STD= looks like this:
21-
#+BEGIN_SRC
25+
A simple class defined with `DEFCLASS/STD` looks like this:
26+
```lisp
2227
(defclass/std example ()
2328
((slot1 slot2 slot3)))
2429
@@ -28,27 +33,27 @@
2833
((SLOT1 :ACCESSOR SLOT1 :INITARG :SLOT1 :INITFORM NIL)
2934
(SLOT2 :ACCESSOR SLOT2 :INITARG :SLOT2 :INITFORM NIL)
3035
(SLOT3 :ACCESSOR SLOT3 :INITARG :SLOT3 :INITFORM NIL)))
31-
#+END_SRC
36+
```
3237
As you can see, by default, the macro adds three options:
33-
1. =:accessor= + the name of the slot
34-
2. =:initarg= + the name of the slot
35-
3. =:initform nil=
38+
1. `:accessor` + the name of the slot
39+
2. `:initarg` + the name of the slot
40+
3. `:initform nil`
3641

37-
If you want to change the =:initform= value, you can use the =:std= option:
38-
#+BEGIN_SRC lisp
42+
If you want to change the `:initform` value, you can use the `:std` option:
43+
```lisp
3944
(defclass std-test ()
4045
((slot :std 1)))
4146
4247
; expands to:
4348
4449
(DEFCLASS STD-TEST ()
4550
((SLOT :ACCESSOR SLOT :INITARG :SLOT :INITFORM 1)))
46-
#+END_SRC
51+
```
4752

48-
If you want to omit the =:initform= option, you have two ways:
49-
1. Use =:std :unbound= explicitly
50-
2. Change the value of =*default-std*=. By default it is set to =T=, so, when the =:std= option is omitted, =:initform= is set to nil. When =*default-std*= is set to nil, =:initform= is omitted when =:std= is omitted.
51-
#+BEGIN_SRC lisp
53+
If you want to omit the `:initform` option, you have two ways:
54+
1. Use `:std :unbound` explicitly
55+
2. Change the value of `*default-std*`. By default it is set to `T`, so, when the `:std` option is omitted, `:initform` is set to nil. When `*default-std*` is set to nil, `:initform` is omitted when `:std` is omitted.
56+
```lisp
5257
(defclass/std omit-std ()
5358
((slot :std :unbound)))
5459
@@ -62,14 +67,14 @@
6267
6368
(DEFCLASS OMIT-STD ()
6469
((SLOT :ACCESSOR SLOT :INITARG :SLOT)))
65-
#+END_SRC
70+
```
6671

67-
=:a=, =:i=, =:r= and =:w= are connected: when all of them are omitted, =:a= and =:i= are inserted by default.
72+
`:a`, `:i`, `:r` and `:w` are connected: when all of them are omitted, `:a` and `:i` are inserted by default.
6873

69-
=:a= stands for =:accessor=, =:i= stands for =:initarg=, =:r= stands for =:reader= and =:w= stands for =:writer=.
74+
`:a` stands for `:accessor`, `:i` stands for `:initarg`, `:r` stands for `:reader` and `:w` stands for `:writer`.
7075

71-
If any of those is present, the default (=:a= and =:i=) is omitted.
72-
#+BEGIN_SRC lisp
76+
If any of those is present, the default (`:a` and `:i`) is omitted.
77+
```lisp
7378
(defclass/std airw ()
7479
((slot1 slot2)
7580
(slot3 slot4 :r)
@@ -87,14 +92,14 @@
8792
(SLOT5 :WRITER SLOT5 :INITFORM NIL)
8893
(SLOT6 :ACCESSOR SLOT6 :INITFORM NIL)
8994
(SLOT7 :READER SLOT7 :INITARG :SLOT7 :INITFORM NIL)))
90-
#+END_SRC
91-
Note that slot7 has an =:ri= option. That's just =:r= and =:i= together.
95+
```
96+
Note that slot7 has an `:ri` option. That's just `:r` and `:i` together.
9297

93-
If you want to use =:r= and =:w= together, use =:a= instead, or you'll get an error. The same stands for =:a= + =:r= and =:a= + =:w=.
98+
If you want to use `:r` and `:w` together, use `:a` instead, or you'll get an error. The same stands for `:a` + `:r` and `:a` + `:w`.
9499

95-
You can choose to add the class name as a prefix for the acessor/reader/writer function. Just put =:with= or =:with-prefix= option.
100+
You can choose to add the class name as a prefix for the acessor/reader/writer function. Just put `:with` or `:with-prefix` option.
96101

97-
#+BEGIN_SRC lisp
102+
```lisp
98103
(defclass/std example ()
99104
((slot1 :with)
100105
(slot2)))
@@ -104,14 +109,14 @@
104109
(DEFCLASS WITH ()
105110
((SLOT1 :ACCESSOR EXAMPLE-SLOT1 :INITARG :SLOT1 :INITFORM NIL)
106111
(SLOT2 :ACCESSOR SLOT2 :INITARG :SLOT2 :INITFORM NIL)))
107-
#+END_SRC
112+
```
108113

109-
To make a slot static (class-allocated), use =:@@= or =:static=.
114+
To make a slot static (class-allocated), use `:@@` or `:static`.
110115

111-
To declare the type of a slot or to add documentation to a slot, use =:type= and =:doc=, respectively.
116+
To declare the type of a slot or to add documentation to a slot, use `:type` and `:doc`, respectively.
112117

113-
For real quick, concise, dense and standard class definitions, use =CLASS/STD=:
114-
#+BEGIN_SRC lisp
118+
For real quick, concise, dense and standard class definitions, use `CLASS/STD`:
119+
```lisp
115120
(class/std example slot1 slot2 slot3)
116121
117122
; which expands to:
@@ -125,10 +130,10 @@
125130
((SLOT1 :ACCESSOR SLOT1 :INITARG :SLOT1 :INITFORM NIL)
126131
(SLOT2 :ACCESSOR SLOT2 :INITARG :SLOT2 :INITFORM NIL)
127132
(SLOT3 :ACCESSOR SLOT3 :INITARG :SLOT3 :INITFORM NIL)))
128-
#+END_SRC
133+
```
129134

130-
You can also add the prefix by default by changing the value of the =*with-prefix*= special variable (defaults to =nil=):
131-
#+BEGIN_SRC lisp
135+
You can also add the prefix by default by changing the value of the `*with-prefix*` special variable (defaults to `nil`):
136+
```lisp
132137
(eval-when (:compile-toplevel :load-toplevel :execute)
133138
(setf *with-prefix* t))
134139
(defclass/std pre ()
@@ -138,10 +143,10 @@
138143
139144
(DEFCLASS PRE ()
140145
((FIX :ACCESSOR PRE-FIX :INITARG :FIX)))
141-
#+END_SRC
146+
```
142147

143148
Unknown keywords are left intact:
144-
#+BEGIN_SRC lisp
149+
```lisp
145150
(defclass/std unknown ()
146151
((slot :unknown :keywords)))
147152
@@ -160,9 +165,9 @@
160165
161166
(DEFCLASS UNKNOWN ()
162167
((SLOT :WRITER SLOT :INITARG :SLOT :INITFORM NIL :KEYWORDS :UNKNOWN)))
163-
#+END_SRC
168+
```
164169
** Examples:
165-
#+BEGIN_SRC lisp
170+
```lisp
166171
(defclass/std computer (gadget)
167172
((screen mouse keyboard :a :type string :with-prefix)
168173
(bluetooth touchpad :wi)
@@ -183,12 +188,12 @@
183188
(PLACE :READER COMPUTER-PLACE :INITFORM NIL :ALLOCATION :CLASS
184189
:DOCUMENTATION "Where it is")
185190
(OWNER :WRITER OWNER :INITFORM "Me" :ALLOCATION :CLASS)))
186-
#+END_SRC
191+
```
187192

188193
Real life examples:
189194

190195
From [[https://github.com/AccelerationNet/cl-inflector/blob/master/langs.lisp][cl-inflector]]:
191-
#+BEGIN_SRC lisp
196+
```lisp
192197
(defclass language ()
193198
((name :accessor name :initarg :name :initform nil)
194199
(plurals :accessor plurals :initarg :plurals :initform nil)
@@ -204,9 +209,9 @@
204209
; or, using CLASS/STD:
205210
206211
(class/std language name plurals singulars uncountables irregulars)
207-
#+END_SRC
212+
```
208213
From [[https://github.com/fukamachi/clack/blob/9804d0b57350032ebdcf8539bae376b5528ac1f6/src/core/handler.lisp][clack]]:
209-
#+BEGIN_SRC lisp
214+
```lisp
210215
(defclass <handler> ()
211216
((server-name :type keyword
212217
:initarg :server-name
@@ -218,9 +223,9 @@
218223
(defclass/std language ()
219224
((server-name :type keyword)
220225
(acceptor)))
221-
#+END_SRC
226+
```
222227
From [[https://github.com/archimag/restas/blob/3e37f868141c785d2468fab342d57cca2e2a40dd/src/route.lisp][RESTAS]]:
223-
#+BEGIN_SRC lisp
228+
```lisp
224229
(defclass route (routes:route)
225230
((symbol :initarg :symbol :reader route-symbol)
226231
(module :initarg :module :initform nil :reader route-module)
@@ -240,9 +245,9 @@
240245
headers variables additional-variables :ri)
241246
(render-method :i :std #'identity)
242247
(header :ir)))
243-
#+END_SRC
248+
```
244249
From [[http://common-lisp.net/project/defclass-star/configuration.lisp.html][defclass-star example]]:
245-
#+BEGIN_SRC lisp
250+
```lisp
246251
(defclass configuration ()
247252
((package-name :type symbol :initarg :package-name :accessor package-name-of)
248253
(package-nicknames :initform '() :initarg :package-nicknames :accessor package-nicknames-of)
@@ -313,9 +318,9 @@
313318
:type (or (function (string)) symbol))
314319
(temp-directory :std (make-pathname :directory "/tmp"))
315320
(working-directory :std *default-pathname-defaults*)))
316-
#+END_SRC
321+
```
317322
From [[https://github.com/jd/cl-hue/blob/master/cl-hue.lisp][cl-hue]]:
318-
#+BEGIN_SRC lisp
323+
```lisp
319324
(defclass light ()
320325
((bridge :initarg :bridge :accessor light-bridge)
321326
(number :initarg :number :accessor light-number)
@@ -354,12 +359,12 @@
354359
(class/std light
355360
bridge number type name modelid uniqueid swversion pointsymbol on brightness
356361
hue saturation xy ct alert effect colormode reachable)
357-
#+END_SRC
362+
```
358363

359-
There's a shortcut to setup a basic printing behaviour of a class, using =printing-unreadably=:
360-
#+BEGIN_SRC lisp
364+
There's a shortcut to setup a basic printing behaviour of a class, using `printing-unreadably`:
365+
```lisp
361366
(printing-unreadably (field2 field3) (class/std myclass field1 field2 field3))
362-
#+END_SRC
367+
```
363368
** Dependencies
364369
This project depends only on the [[http://common-lisp.net/project/anaphora/][Anaphora]] library. The test package uses the [[github.com/fukamachi/prove][prove]] test library.
365370

@@ -373,11 +378,11 @@
373378
This library is tested under SBCL, CCL and CLISP Common Lisp implementations.
374379

375380
To run all the defined tests, use:
376-
#+BEGIN_SRC lisp
381+
```lisp
377382
* (asdf:test-system :defclass-std)
378383
; prints lots of stuff...
379384
; => T
380-
#+END_SRC
385+
```
381386
Tests are also ran with [[https://travis-ci.org/EuAndreh/defclass-std][Travis CI]] using [[https://github.com/luismbo/cl-travis][cl-travis]] and [[https://github.com/KeenS/CIM][CIM]]. Check it out!
382387

383388
** Authors
@@ -388,3 +393,4 @@
388393
** License
389394

390395
Licensed under the LLGPL License.
396+

defclass-std.asd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
((:file "defclass-std"))))
1515
:description "A shortcut macro to write DEFCLASS forms quickly."
1616
:long-description #.(uiop:read-file-string
17-
(uiop:subpathname *load-pathname* "README.org"))
17+
(uiop:subpathname *load-pathname* "README.md"))
1818
:in-order-to ((test-op (test-op defclass-std-test))))

0 commit comments

Comments
 (0)