Skip to content

Commit 34160ac

Browse files
committed
extend a bit devel macroses
1 parent f6101b2 commit 34160ac

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src-clj/libmisc_clj/misc.clj

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@
191191
([^String hostname ^Integer port]
192192
(host-port-up? hostname port host-up-timeout))
193193
([^String hostname ^Integer port ^Integer timeout]
194-
(try
195-
(let [sock-addr (InetSocketAddress. hostname port)]
196-
(with-open [sock (Socket.)]
197-
(.connect sock sock-addr timeout)
198-
true))
199-
(catch Throwable _ false))))
194+
(try
195+
(let [sock-addr (InetSocketAddress. hostname port)]
196+
(with-open [sock (Socket.)]
197+
(.connect sock sock-addr timeout)
198+
true))
199+
(catch Throwable _ false))))
200200

201201
(defn maybe?
202202
"Returns `true` if X is `nil`, otherwise calls (F X).
@@ -231,9 +231,17 @@
231231
(-> s .trim .isEmpty not)
232232
false))
233233

234-
(defmacro ^:private when-let*
234+
(defmacro when-let*
235+
"The extended version of when-let what allows multiple bindings"
235236
([bindings & body]
236237
(if (seq bindings)
237238
`(when-let [~(first bindings) ~(second bindings)]
238239
(when-let* ~(drop 2 bindings) ~@body))
239-
`(do ~@body))))
240+
`(do ~@body))))
241+
242+
(defmacro def-
243+
"Yields a private definitions as 'def the same way as defn- does"
244+
[name & body]
245+
(list* `def (with-meta name
246+
(assoc (meta name) :private true))
247+
body))

0 commit comments

Comments
 (0)