mirror of
https://github.com/janet-lang/janet
synced 2024-12-26 08:20:27 +00:00
Add forever macro and add names to anon fns.
Adding names to anon functions that may error improves stack traces, especially for user visible traces.
This commit is contained in:
parent
a1feb32a2f
commit
f580d2e41a
@ -2,6 +2,7 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## Unreleased - ???
|
## Unreleased - ???
|
||||||
|
- Add `forever` macro.
|
||||||
- Add `any?` predicate to core.
|
- Add `any?` predicate to core.
|
||||||
- Add `jpm list-pkgs` subcommand to see which package aliases are in the listing.
|
- Add `jpm list-pkgs` subcommand to see which package aliases are in the listing.
|
||||||
- Add `jpm list-installed` subcommand to see which packages are installed.
|
- Add `jpm list-installed` subcommand to see which packages are installed.
|
||||||
|
@ -516,6 +516,11 @@
|
|||||||
(with-syms [iter]
|
(with-syms [iter]
|
||||||
~(do (var ,iter ,n) (while (> ,iter 0) ,;body (-- ,iter)))))
|
~(do (var ,iter ,n) (while (> ,iter 0) ,;body (-- ,iter)))))
|
||||||
|
|
||||||
|
(defmacro forever
|
||||||
|
"Evaluate body forever in a loop, or until a break statement."
|
||||||
|
[& body]
|
||||||
|
~(while true ,;body))
|
||||||
|
|
||||||
(defmacro each
|
(defmacro each
|
||||||
"Loop over each value in ds. Returns nil."
|
"Loop over each value in ds. Returns nil."
|
||||||
[x ds & body]
|
[x ds & body]
|
||||||
@ -2173,12 +2178,12 @@
|
|||||||
(buffer/push-string buf "\n")))
|
(buffer/push-string buf "\n")))
|
||||||
(var returnval nil)
|
(var returnval nil)
|
||||||
(run-context {:chunks chunks
|
(run-context {:chunks chunks
|
||||||
:on-compile-error (fn [msg errf &]
|
:on-compile-error (fn compile-error [msg errf &]
|
||||||
(error (string "compile error: " msg)))
|
(error (string "compile error: " msg)))
|
||||||
:on-parse-error (fn [p x]
|
:on-parse-error (fn parse-error [p x]
|
||||||
(error (string "parse error: " (parser/error p))))
|
(error (string "parse error: " (parser/error p))))
|
||||||
:fiber-flags :i
|
:fiber-flags :i
|
||||||
:on-status (fn [f val]
|
:on-status (fn on-status [f val]
|
||||||
(if-not (= (fiber/status f) :dead)
|
(if-not (= (fiber/status f) :dead)
|
||||||
(error val))
|
(error val))
|
||||||
(set returnval val))
|
(set returnval val))
|
||||||
@ -2770,17 +2775,17 @@
|
|||||||
"k" (fn [&] (set *compile-only* true) (set *exit-on-error* false) 1)
|
"k" (fn [&] (set *compile-only* true) (set *exit-on-error* false) 1)
|
||||||
"n" (fn [&] (set *colorize* false) 1)
|
"n" (fn [&] (set *colorize* false) 1)
|
||||||
"m" (fn [i &] (setdyn :syspath (in args (+ i 1))) 2)
|
"m" (fn [i &] (setdyn :syspath (in args (+ i 1))) 2)
|
||||||
"c" (fn [i &]
|
"c" (fn c-switch [i &]
|
||||||
(def e (dofile (in args (+ i 1))))
|
(def e (dofile (in args (+ i 1))))
|
||||||
(spit (in args (+ i 2)) (make-image e))
|
(spit (in args (+ i 2)) (make-image e))
|
||||||
(set *no-file* false)
|
(set *no-file* false)
|
||||||
3)
|
3)
|
||||||
"-" (fn [&] (set *handleopts* false) 1)
|
"-" (fn [&] (set *handleopts* false) 1)
|
||||||
"l" (fn [i &]
|
"l" (fn l-switch [i &]
|
||||||
(import* (in args (+ i 1))
|
(import* (in args (+ i 1))
|
||||||
:prefix "" :exit *exit-on-error*)
|
:prefix "" :exit *exit-on-error*)
|
||||||
2)
|
2)
|
||||||
"e" (fn [i &]
|
"e" (fn e-switch [i &]
|
||||||
(set *no-file* false)
|
(set *no-file* false)
|
||||||
(eval-string (in args (+ i 1)))
|
(eval-string (in args (+ i 1)))
|
||||||
2)
|
2)
|
||||||
|
Loading…
Reference in New Issue
Block a user