Skip to content

Commit c720958

Browse files
committed
Add with-names to utilities
1 parent 49b6358 commit c720958

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.2.1
1+
8.3.0

utilities.lisp

+16-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
(:use :cl)
66
(:export
77
#:parse-docstring-body
8-
#:parse-simple-body))
8+
#:parse-simple-body
9+
#:with-names))
910

1011
(in-package :org.tfeb.hax.utilities)
1112

@@ -36,3 +37,17 @@ a list of forms."
3637
(multiple-value-bind (decls forms)
3738
(parse-simple-body doc/decls/forms)
3839
(values nil decls forms))))
40+
41+
(defmacro with-names ((&rest clauses) &body forms)
42+
"Bind a bunch of variables to fresh symbols with the same name
43+
44+
Optionally you can specify the name by giving a clause as (var <string-designator>)."
45+
`(let ,(mapcar (lambda (clause)
46+
(etypecase clause
47+
(symbol
48+
`(,clause (make-symbol ,(string clause))))
49+
(cons
50+
(destructuring-bind (name sd) clause
51+
`(,name (make-symbol (string ,sd)))))))
52+
clauses)
53+
,@forms))

0 commit comments

Comments
 (0)