-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R functions arglist #22
Comments
Nice. This is related to #8 . |
Just to leave it before pull request. Formals is defined as below: (def ^:private empty-symbol (symbol ""))
(defn formals
[{:keys [code class]}]
(when (= class ["function"])
(let [args (-> (format "formals(%s)" code)
r
r->clj)
{:keys [obl opt]} (reduce (fn [m [k v]]
(let [selector (if (and (= empty-symbol v)
(not (seq (:obl m)))) :obl :opt)]
(update m selector conj (symbol k))))
{:obl [] :opt []}
args)]
(cond
(and (seq obl)
(seq opt)) (list (conj obl '& {:keys opt}))
(seq obl) (list obl)
(seq opt) (list ['& {:keys opt}])
:else '([])))))
(alter-meta! #'stats/arima0 assoc :arglists (formals stats/arima0))
(meta #'stats/arima0)
;; => {:asdf 12, :name arima0, :ns #namespace[stats], :arglists ([x & {:keys [order seasonal xreg include.mean delta transform.pars fixed init method n.cond optim.control]}])} Adding metadata can be done during |
Sorry for duplicate. |
Hi @genmeblog .
(edit: typo) |
Great! Regarding 4: this would be the best solution. But remember that meta are attached to symbol not to object itself. |
should we close this? |
I prepared POC for adding arglist for RObjects acting as function using
formals
. It can be helpful for REPL driven development. Arglists conform calling way in clojuress (associative destructuring on variadic position)Examples:
formals
can be used to create:arglists
meta tag.(I checked and it works on CIDER)
The text was updated successfully, but these errors were encountered: