Skip to content

Added ns-publics plus 0 arity ns-map #384

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions pixie/stdlib.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -2022,6 +2022,13 @@ For more information, see http://clojure.org/special_forms#binding-forms"}
(cons result (keep f rest))
(keep f rest)))))))

(defn ns-map
"Returns vars in the namespace, defaults to *ns* if no namespace is provided"
([]
(ns-map *ns*))
([ns]
(-ns-map ns)))

(defn refer
{:doc "Refer to the specified vars from a namespace directly.

Expand Down Expand Up @@ -2320,7 +2327,7 @@ Expands to calls to `extend-type`."

(defn float
{:doc "Converts a number to a float."
:since "0.1"}
:since "0.1"}
[x]
(-float x))

Expand Down Expand Up @@ -2348,7 +2355,7 @@ Expands to calls to `extend-type`."

(defn int
{:doc "Converts a number to an integer."
:since "0.1"}
:since "0.1"}
[x]
(-int x))

Expand Down Expand Up @@ -2707,3 +2714,13 @@ Calling this function on something that is not ISeqable returns a seq with that
(if (satisfies? IComparable x)
(-compare x y)
(throw [::ComparisonError (str x " does not satisfy IComparable")])))

(defn ns-publics
"Returns the public vars in a given namespace. If no namespace is given, default
to the current namespace."
([]
(ns-publics *ns*))
([ns]
(->> (ns-map ns)
(remove (comp :private meta deref second))
(into {}))))
2 changes: 1 addition & 1 deletion pixie/vm/stdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def in_ns(ns_name):

return nil

@as_var("ns-map")
@as_var("-ns-map")
def ns_map(ns):
from pixie.vm.symbol import Symbol
affirm(isinstance(ns, Namespace) or isinstance(ns, Symbol), u"ns must be a symbol or a namespace")
Expand Down