1
0
mirror of https://github.com/janet-lang/janet synced 2025-06-21 07:54:12 +00:00

Use spork indent on boot.janet.

This commit is contained in:
Calvin Rose 2020-05-05 09:17:09 -05:00
parent 125cd222bb
commit e3862b86b5

View File

@ -240,8 +240,8 @@
[& body] [& body]
(let [f (gensym) r (gensym)] (let [f (gensym) r (gensym)]
~(let [,f (,fiber/new (fn [] ,;body) :ie) ~(let [,f (,fiber/new (fn [] ,;body) :ie)
,r (,resume ,f)] ,r (,resume ,f)]
[(,not= :error (,fiber/status ,f)) ,r]))) [(,not= :error (,fiber/status ,f)) ,r])))
(defmacro and (defmacro and
"Evaluates to the last argument if all preceding elements are truthy, otherwise "Evaluates to the last argument if all preceding elements are truthy, otherwise
@ -369,7 +369,7 @@
"Similar to with, but if binding is false or nil, evaluates "Similar to with, but if binding is false or nil, evaluates
the falsey path. Otherwise, evaluates the truthy path. In both cases, the falsey path. Otherwise, evaluates the truthy path. In both cases,
ctor is bound to binding." ctor is bound to binding."
[[binding ctor dtor] truthy &opt falsey ] [[binding ctor dtor] truthy &opt falsey]
~(if-let [,binding ,ctor] ~(if-let [,binding ,ctor]
,(apply defer [(or dtor :close) binding] [truthy]) ,(apply defer [(or dtor :close) binding] [truthy])
,falsey)) ,falsey))
@ -618,9 +618,9 @@
(case (length functions) (case (length functions)
0 nil 0 nil
1 (in functions 0) 1 (in functions 0)
2 (let [[f g] functions] (fn [& x] (f (g ;x)))) 2 (let [[f g] functions] (fn [& x] (f (g ;x))))
3 (let [[f g h] functions] (fn [& x] (f (g (h ;x))))) 3 (let [[f g h] functions] (fn [& x] (f (g (h ;x)))))
4 (let [[f g h i] functions] (fn [& x] (f (g (h (i ;x)))))) 4 (let [[f g h i] functions] (fn [& x] (f (g (h (i ;x))))))
(let [[f g h i] functions] (let [[f g h i] functions]
(comp (fn [x] (f (g (h (i x))))) (comp (fn [x] (f (g (h (i x)))))
;(tuple/slice functions 4 -1))))) ;(tuple/slice functions 4 -1)))))
@ -1070,7 +1070,7 @@
[bindings & body] [bindings & body]
(def dyn-forms (def dyn-forms
(seq [i :range [0 (length bindings) 2]] (seq [i :range [0 (length bindings) 2]]
~(setdyn ,(bindings i) ,(bindings (+ i 1))))) ~(setdyn ,(bindings i) ,(bindings (+ i 1)))))
~(,resume (,fiber/new (fn [] ,;dyn-forms ,;body) :p))) ~(,resume (,fiber/new (fn [] ,;dyn-forms ,;body) :p)))
(defmacro with-vars (defmacro with-vars
@ -1084,12 +1084,12 @@
(def setnew (seq [i :range [0 len 2]] ['set (vars i) (vars (+ i 1))])) (def setnew (seq [i :range [0 len 2]] ['set (vars i) (vars (+ i 1))]))
(def restoreold (seq [i :range [0 len 2]] ['set (vars i) (temp (/ i 2))])) (def restoreold (seq [i :range [0 len 2]] ['set (vars i) (temp (/ i 2))]))
(with-syms [ret f s] (with-syms [ret f s]
~(do ~(do
,;saveold ,;saveold
(def ,f (,fiber/new (fn [] ,;setnew ,;body) :ti)) (def ,f (,fiber/new (fn [] ,;setnew ,;body) :ti))
(def ,ret (,resume ,f)) (def ,ret (,resume ,f))
,;restoreold ,;restoreold
(if (= (,fiber/status ,f) :dead) ,ret (,propagate ,ret ,f))))) (if (= (,fiber/status ,f) :dead) ,ret (,propagate ,ret ,f)))))
(defn partial (defn partial
"Partial function application." "Partial function application."
@ -1443,7 +1443,7 @@
(if (= key nil) (if (= key nil)
(onmatch) (onmatch)
~(do (def ,$val (,get ,$dict ,key)) ~(do (def ,$val (,get ,$dict ,key))
,(match-1 [(in pattern key) [not= nil $val]] $val aux seen))))) ,(match-1 [(in pattern key) [not= nil $val]] $val aux seen)))))
,sentinel))) ,sentinel)))
:else ~(if (= ,pattern ,expr) ,(onmatch) ,sentinel))) :else ~(if (= ,pattern ,expr) ,(onmatch) ,sentinel)))
@ -1751,8 +1751,8 @@
:array (tuple/slice (map freeze x)) :array (tuple/slice (map freeze x))
:tuple (tuple/slice (map freeze x)) :tuple (tuple/slice (map freeze x))
:table (if-let [p (table/getproto x)] :table (if-let [p (table/getproto x)]
(freeze (merge (table/clone p) x)) (freeze (merge (table/clone p) x))
(struct ;(map freeze (kvs x)))) (struct ;(map freeze (kvs x))))
:struct (struct ;(map freeze (kvs x))) :struct (struct ;(map freeze (kvs x)))
:buffer (string x) :buffer (string x)
x)) x))
@ -2148,7 +2148,7 @@
(when f (when f
(def res (def res
(try (do (file/read f 1) true) (try (do (file/read f 1) true)
([err] nil))) ([err] nil)))
(file/close f) (file/close f)
res)))) res))))
@ -2170,8 +2170,8 @@
(when (mod-filter checker path) (when (mod-filter checker path)
(if (function? p) (if (function? p)
(when-let [res (p path)] (when-let [res (p path)]
(set ret [res mod-kind]) (set ret [res mod-kind])
(break)) (break))
(do (do
(def fullpath (string (module/expand-path path p))) (def fullpath (string (module/expand-path path p)))
(when (fexists fullpath) (when (fexists fullpath)