Avoid mutating HyLists in hy.contrib
This commit is contained in:
parent
9ddb3b1031
commit
95ad5a01c8
@ -84,13 +84,9 @@
|
||||
(setv comment (HyString))
|
||||
(if (= (type (first bodies)) HyString)
|
||||
(setv [comment bodies] (head-tail bodies)))
|
||||
(setv ret `(do))
|
||||
(.append ret '(import [hy.contrib.multi [MultiDispatch]]))
|
||||
(for [body bodies]
|
||||
(setv [let-binds body] (head-tail body))
|
||||
(.append ret
|
||||
`(with-decorator MultiDispatch (defn ~name ~let-binds ~comment ~@body))))
|
||||
ret)
|
||||
(+ '(do (import [hy.contrib.multi [MultiDispatch]])) (lfor
|
||||
[let-binds #* body] bodies
|
||||
`(with-decorator MultiDispatch (defn ~name ~let-binds ~comment ~@body)))))
|
||||
(do
|
||||
(setv [lambda-list body] (head-tail bodies))
|
||||
`(setv ~name (fn* ~lambda-list ~@body)))))
|
||||
|
@ -89,7 +89,7 @@ splits a fn argument list into sections based on &-headers.
|
||||
returns an OrderedDict mapping headers to sublists.
|
||||
Arguments without a header are under None.
|
||||
"
|
||||
(setv headers '[&optional &rest &kwonly &kwargs]
|
||||
(setv headers ['&optional '&rest '&kwonly '&kwargs]
|
||||
sections (OrderedDict [(, None [])])
|
||||
header None)
|
||||
(for [arg form]
|
||||
@ -169,7 +169,7 @@ Arguments without a header are under None.
|
||||
#{})))))
|
||||
(defn handle-args-list [self]
|
||||
(setv protected #{}
|
||||
argslist `[])
|
||||
argslist [])
|
||||
(for [[header section] (-> self (.tail) first lambda-list .items)]
|
||||
(if header (.append argslist header))
|
||||
(cond [(in header [None '&rest '&kwargs])
|
||||
|
Loading…
Reference in New Issue
Block a user