mirror of
https://github.com/janet-lang/janet
synced 2024-11-25 01:37:19 +00:00
Add defn- form for private defs.
This commit is contained in:
parent
3b2658150e
commit
8445b1187f
@ -26,6 +26,12 @@
|
||||
(def args (array-concat [] name 'macro more))
|
||||
(apply defn* args))))
|
||||
|
||||
(defmacro defn-
|
||||
"Define a private function that will not be exported."
|
||||
[name & more]
|
||||
(apply tuple (array-concat
|
||||
['defn name 'private] more)))
|
||||
|
||||
(defmacro when
|
||||
"(when cond & body)
|
||||
Evaluates the body when the condition is true. Otherwise returns nil."
|
||||
@ -80,7 +86,10 @@
|
||||
(defmacro or [x y] (tuple 'if x true y))
|
||||
(defmacro and [x y] (tuple 'if x y false))
|
||||
|
||||
(def identity (fn [x] x))
|
||||
(defn identity
|
||||
"(identity x)
|
||||
A function that returns its first argument."
|
||||
[x] x)
|
||||
|
||||
(def seq (do
|
||||
(defn array-seq [x]
|
||||
@ -294,7 +303,8 @@
|
||||
} (apply table args))
|
||||
(defn one [pair]
|
||||
(def [k v] pair)
|
||||
(put *env* (symbol (if prefix prefix "") k) v))
|
||||
(when (not (get v 'private))
|
||||
(put *env* (symbol (if prefix prefix "") k) v)))
|
||||
(doseq (map one (pairs env))))
|
||||
|
||||
(defn repl []
|
||||
|
Loading…
Reference in New Issue
Block a user