FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Added ns-publics plus 0 arity ns-map by emidln · Pull Request #384 · pixie-lang/pixie · GitHub

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .pxi  (1) .py  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
21 changes: 19 additions & 2 deletions pixie/stdlib.pxi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL