1
0
mirror of https://github.com/janet-lang/janet synced 2025-12-13 20:18:06 +00:00

Assertf with no arguments does not make sense.

This commit is contained in:
Calvin Rose
2024-11-24 19:14:18 -06:00
parent e3159bb0f5
commit 2bceba4a7a
2 changed files with 11 additions and 7 deletions

View File

@@ -154,11 +154,6 @@
,v
(,error ,(if err err (string/format "assert failure in %j" x))))))
(defmacro assertf
"Convenience macro that combines `assert` and `string/format`."
[x & args]
~(as-macro ,assert ,x (,string/format ,;args)))
(defmacro defdyn
``Define an alias for a keyword that is used as a dynamic binding. The
alias is a normal, lexically scoped binding that can be used instead of
@@ -209,6 +204,16 @@
[fmt & args]
(error (string/format fmt ;args)))
(defmacro assertf
"Convenience macro that combines `assert` and `string/format`."
[x fmt & args]
(def v (gensym))
~(do
(def ,v ,x)
(if ,v
,v
(,errorf ,fmt ,;args))))
(defmacro default
``Define a default value for an optional argument.
Expands to `(def sym (if (= nil sym) val sym))`.``