Skip to content

Commit

Permalink
use if-else as an enhanced replacement for if
Browse files Browse the repository at this point in the history
  • Loading branch information
jbr committed Dec 23, 2014
1 parent 52e559f commit 2957f60
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions include/macros.sibilant
Expand Up @@ -358,8 +358,7 @@

("(function() {" (apply indent lines) "})()"))


(macro if-else (...args)
(macro if (...args)
("(function() {"
(indent
(join " else "
Expand Down Expand Up @@ -437,7 +436,7 @@
(macro var (...pairs)
(var destructured [])
(bulk-map pairs (#(lhs rhs)
(if-else
(if
(= 'list (first lhs))
(do
(var symbol (^symbol))
Expand Down Expand Up @@ -468,7 +467,7 @@
("[ " (join ", " (map args translate)) " ]"))

(each (arg) args
(if-else
(if
(= "..." arg) (assign dots true)
dots (do (arg-segments.push (translate arg))
(assign dots false))
Expand Down
4 changes: 2 additions & 2 deletions test/test.sibilant
Expand Up @@ -447,7 +447,7 @@ thunk(\"world\");


(assert-translation
"(if-else a b c d e (do (g) h))"
"(if a b c d e (do (g) h))"
"(function() {
if (a) {
return b;
Expand All @@ -461,7 +461,7 @@ thunk(\"world\");


(assert-translation
"(if-else a b c d e)"
"(if a b c d e)"
"(function() {
if (a) {
return b;
Expand Down

0 comments on commit 2957f60

Please sign in to comment.