mirror of
https://github.com/janet-lang/janet
synced 2025-01-12 08:30:26 +00:00
parent
ae5dc8c45b
commit
df32cd0aca
@ -2,6 +2,7 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## Unreleased - ???
|
||||
- Add `tracev` macro.
|
||||
- Fix compiler bug that emitted incorrect code in some cases for while loops that create closures.
|
||||
- Add `:fresh` option to `(import ...)` to overwrite the module cache.
|
||||
- `(range x y 0)` will return an empty array instead of hanging forever.
|
||||
|
@ -947,30 +947,14 @@
|
||||
(tuple 'fn (tuple '& $args) (tuple/slice parts 0)))
|
||||
|
||||
(defmacro tracev
|
||||
"Displays the variables or literals listed, providing both the name and
|
||||
and the value for variables. Designed for quick debugging of values. Returns
|
||||
the traced forms: nil for none, the form itself for one, and a tuple of the
|
||||
forms for many."
|
||||
[& forms]
|
||||
(with-syms [results var]
|
||||
~(do
|
||||
(def ,results @[])
|
||||
,;(map (fn [form]
|
||||
~(do
|
||||
(def ,var ,form)
|
||||
(eprintf (string "trace "
|
||||
(dyn :pretty-format "%q")
|
||||
" is "
|
||||
(dyn :pretty-format "%q"))
|
||||
',form
|
||||
,var)
|
||||
(eflush)
|
||||
(array/push ,results ,var)))
|
||||
forms)
|
||||
(case (length ,results)
|
||||
0 nil
|
||||
1 (,results 0)
|
||||
(tuple ;,results)))))
|
||||
"Print a value and a description of the form that produced that value to
|
||||
stderr. Evaluates to x."
|
||||
[x]
|
||||
(def s (gensym))
|
||||
~(let [,s ,x]
|
||||
(,eprinf "trace %j is " ',x)
|
||||
(,eprintf (,dyn :pretty-format "%q") ,s)
|
||||
,s))
|
||||
|
||||
(defmacro ->
|
||||
"Threading macro. Inserts x as the second value in the first form
|
||||
|
Loading…
Reference in New Issue
Block a user