Plaster
New
List
Login
text
apl
aspx
asterisk
brainfuck
c
c++hdr
c++src
cassandra
ceylon
clojure
clojurescript
cmake
cobol
coffeescript
common-lisp
crystal
csharp
css
cypher-query
cython
d
dart
diff
django
dockerfile
dylan
ebnf
ecl
ecmascript
edn
eiffel
ejs
elm
erb
erlang
ez80
factor
fcl
feature
forth
fortran
fragment
gfm
go
gql
groovy
gss
haml
handlebars-template
haskell
haxe
hive
html
http
httpd-php
httpd-php-open
hxml
ini
java
javascript
json
jsp
jsx
julia
kotlin
latex
less
literate-haskell
lua
mariadb
markdown
mbox
mirc
mscgen
msgenny
mssql
mumps
mysql
n-triples
nesc
nginx-conf
nsis
objectivec
octave
oz
pascal
perl
pgp
pgp-keys
pgp-signature
pgsql
php
pig
plsql
properties
protobuf
puppet
python
q
rpm-changes
rpm-spec
rsrc
ruby
rustsrc
sas
sass
scala
scheme
scss
sieve
slim
smarty
solr
soy
sparql-query
spreadsheet
sql
squirrel
stex
styl
swift
systemverilog
tcl
textile
tiddlywiki
tiki
tlv
tornado
ttcn-asn
ttcn-cfg
turtle
twig
typescript
typescript-jsx
vb
vbscript
velocity
verilog
vertex
vhdl
vue
webidl
xml
xml-dtd
xquery
xu
yaml
z80
default
Visibility:
public
unlisted
private
(defmacro define-tuple (class-name parents slots &optional documentation) "This is just to save my hands, since Netfarm class slots are mostly disjoint and have the same printer basically. CLASS-NAME is the name of the slot, PARENTS should be called DIRECT-SUPERCLASSES to be accurate, SLOTS are a modified slot description list, and DOCUMENTATION is the docstring. SLOTS takes the form (name . plist), where plist contains: - :READER, the reader/setter of the slot (defaults to CLASS-SLOT like DEFSTRUCT), - :READ-ONLY, truthy if the slot should be read-only, - :INITARG, the keyword argument, - :INITFORM, the default value. This generates the DEFCLASS form, and a method on PRINT-OBJECT." (let ((not-found (gensym "NOT-FOUND")) (slot-alist nil)) (flet ((getf-or-default (list value &optional default) (let ((value (getf list value not-found))) (if (eql value not-found) default value)))) `(progn (defclass ,class-name ,parents ,(loop for (name . arguments) in slots for reader-name = (or (getf arguments :reader) (intern (format nil "~a-~a" class-name name))) do (push (cons name reader-name) slot-alist) collect `(,name :initarg ,(getf-or-default arguments :initarg (intern (symbol-name name) 'keyword)) :initform ,(getf-or-default arguments :initform `(error ,(format nil "~a is required" name))) ,(if (getf arguments :read-only) :reader :accessor) ,reader-name)) ,@(unless (null documentation) (list (list :documentation documentation)))) (defmethod print-object ((object ,class-name) stream) (print-unreadable-object (object stream :type t :identity t) (pprint-logical-block (stream nil) ,@(loop for ((name . reader) . continuep) on (reverse slot-alist) collect `(progn (write-char #\: stream) (write-string ,(symbol-name name) stream) (write-char #\Space stream) (pprint-newline :miser stream) (prin1 (,reader object) stream) ,@(when continuep '((write-char #\Space stream) (pprint-newline :linear stream))))))))))))