1
0
mirror of https://github.com/janet-lang/janet synced 2024-06-26 07:03:16 +00:00

simplify if-let logic

This commit is contained in:
primo-ppcg 2023-06-11 12:09:58 +07:00
parent 94722e566c
commit 2c3ca2984e

View File

@ -674,21 +674,7 @@
(do
(def bl (in bindings i))
(def br (in bindings (+ 1 i)))
(def atm (idempotent? bl))
(def sym (if atm bl (gensym)))
(if atm
# Simple binding
(tuple 'do
(tuple 'def sym br)
(tuple 'if sym (aux (+ 2 i)) fal))
# Destructured binding
(tuple 'do
(tuple 'def sym br)
(tuple 'if sym
(tuple 'do
(tuple 'def bl sym)
(aux (+ 2 i)))
fal))))))
(tuple 'if (tuple 'def bl br) (aux (+ 2 i)) fal))))
(aux 0))
(defmacro when-let