e7c5f95a |
1 | (in-package :lisp-on-lines) |
2 | |
3 | (define-description description ()) |
4 | |
e7c5f95a |
5 | (defun find-description (name) |
6 | (slot-value (find-description-class name) 'instance)) |
7 | |
8 | (defun description-attributes (description) |
9 | (closer-mop:class-slots (find-description-class description))) |
10 | |
11 | (define-layered-function attributes (description)) |
12 | |
13 | (define-layered-method attributes (description) |
14 | (description-attributes description)) |
15 | |
16 | ;;;!-- TODO: This is a prime candidate for optimization |
17 | (defun find-attribute (description attribute-name) |
18 | (find attribute-name (description-attributes description) :key #'attribute-name)) |
19 | |
20 | (define-display ((description description)) |
21 | (format *display* "~{~A~%~}" |
22 | (mapcar |
23 | (lambda (attribute) |
24 | (with-output-to-string (*display*) |
25 | (display-attribute attribute))) |
26 | (attributes description)))) |
27 | |
4867c86f |
28 | |
e7c5f95a |
29 | (define-layered-method description-of (object) |
30 | (find-description 't)) |
31 | |
32 | (define-layered-method description-of ((symbol symbol)) |
33 | (find-description 'symbol)) |
34 | |
35 | (define-description symbol () |
36 | ((identity :label "Symbol:") |
37 | (name |
38 | :function #'symbol-name |
39 | :label "Name:") |
40 | (value |
41 | :label "Value:" |
42 | :function |
43 | (lambda (symbol) |
44 | (if (boundp symbol) |
45 | (symbol-value symbol) |
46 | "<UNBOUND>"))) |
47 | (package :function #'symbol-package |
48 | :label "Package:") |
49 | (function :label "Function:" |
50 | :function |
51 | (lambda (symbol) |
52 | (if (fboundp symbol) |
53 | (symbol-function symbol) |
54 | "<UNBOUND>"))))) |
55 | |
56 | |
57 | |
58 | |
59 | |
60 | |
61 | |
62 | |
63 | |
64 | |
65 | |