-
Notifications
You must be signed in to change notification settings - Fork 7
/
clojure-packages.lisp
146 lines (129 loc) · 4.76 KB
/
clojure-packages.lisp
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
(in-package #:cloture)
(eval-always
(defvar *clojure-packages*
(tg:make-weak-hash-table :weakness :key))
(defun mark-clojure-package (package)
(let ((package (find-package package)))
(synchronized ('*clojure-packages*)
(setf (href *clojure-packages* package) t))))
(defun clojure-package? (package)
(href *clojure-packages* (find-package package)))
(defun clojure-symbol? (symbol)
(clojure-package? (symbol-package symbol))))
(defmacro declaim-clojure-packages (&rest packages)
`(eval-always
(mapc #'mark-clojure-package ',packages)))
(defmacro define-clojure-package (name &body body)
`(progn
;; Use define-package instead of defpackage so SBCL doesn't
;; complain about package variance.
(uiop:define-package ,name ,@body)
(declaim-clojure-packages ,name)))
(define-clojure-package :clojure-classes
(:use))
(define-clojure-package "clojure.core"
(:nicknames "clj")
(:use)
(:export . #.(append
(serapeum:lines
(alexandria:read-file-into-string
(asdf:system-relative-pathname "cloture" "core-syms.txt")))
;; Some CL stuff it is nice to have available.
lambda-list-keywords
'("&" "var" "true" "false" "nil"
"quote" "if" "do" "def" "recur" "throw" "try" "catch" "finally"
"def-"
"&env" "&form"
"invoke" "equiv" "lookup"
"contains-key?" "kv-reduce"
"new"
"Fn"
"set!"
"imul"
"IAssociative"
"ICollection" "-conj"
"IComparable"
"ICounted"
"IDeref"
"IEditableCollection" "as-transient"
"IEmptyableCollection"
"IEquiv"
"IFn"
"IHash"
"IIndexable"
"IIndexed"
"IIterable"
"IKVReduce"
"ILookup"
"IMap" "-dissoc"
"IMeta"
"INext"
"IPending"
"IReduce" "internal-reduce"
"IReversible"
"ISeq"
"ISeqable"
"ISequential"
"ISorted"
"IStack"
"IVector" "assoc-n"
"IWithMeta"
"Object" "toString" ".toString"
"Thread" "Thread."
"Throwable" "Throwable."
".getMessage" ".getCause"
".getStackTrace" ".printStackTrace"
"Exception" "Exception."
"Error" "Error."
"RuntimeException" "RuntimeException."
"IllegalArgumentException" "IllegalArgumentException."
"IllegalStateException" "IllegalStateException."
"AssertionError" "AssertionError."
"ArityException" "ArityException."
"IllegalAccessError" "IllegalAccessError."
".getClassName"
"Integer/MAX_VALUE"
"Integer/MIN_VALUE"
"Long/MIN_VALUE"
"Long/MAX_VALUE"
"atom?"
;; These aren't part of Clojure but the REPL needs
;; them (and Leiningen provides them).
"exit" "quit"))))
(define-clojure-package "clojure.pprint"
(:use)
(:export . #.(serapeum:lines
(alexandria:read-file-into-string
(asdf:system-relative-pathname "cloture" "pprint-syms.txt")))))
(define-clojure-package "clojure.set"
(:use)
(:export "select" "union" "difference" "intersection" "subset?" "superset?"))
(define-clojure-package "clojure.string"
(:use)
(:export "starts-with?" "ends-with?" "join" "replace" "re-quote-replacement" "upper-case"))
(define-clojure-package "clojure.template"
(:use)
(:export "apply-template" "do-template"))
(define-clojure-package "clojure.stacktrace"
(:use)
(:export "print-cause-trace" "print-stack-trace" "print-throwable" "root-cause"))
(define-clojure-package "clojure.walk"
(:use)
(:export "postwalk" "postwalk-demo" "postwalk-replace"))
(define-clojure-package "user"
(:use "clojure.core"))
(define-clojure-package "cloture"
(:use)
(:export "funcall" "declare-keywords" "aref" "parse-integer" "expt"))
(define-clojure-package #:cloture.impl
(:documentation "Package used for the Clojure shortcut reader macro.")
(:use
"clojure.core"
"clojure.pprint"
"clojure.set"
"clojure.string"
"clojure.template"
"clojure.stacktrace"
"clojure.walk"
"cloture")
(:shadowing-import-from "clojure.core" "replace"))