7 ms·
(when (> x ) (printf a) (return b)) (cond ((> x 3) (printf a) (return b)) ((< x 2) (printf b) (return a)) (t (r
by kazinator 8y ago
(when (> x )
(printf a)
(return b))
(cond
((> x 3) (printf a)
(return b))
((< x 2) (printf b)
(return a))
(t (return c)))
Nobody who works with Lisps thinks in terms of "do I need double parentheses". You just know that if takes two or three expressions, when takes an expression followed by zero or more forms, cond takes a sequence of zero or more clauses which consist of a test followed by a body of zero or more forms.
If you're designing an S-exp syntax for something else, it's probably best to keep the familiar things the same; don't make some different if and such.
The Lisp if maps naturally to the ?: ternary operator; cond, when and unless can compile to cascaded if/else if/else.
- evmar 8y agoYes, but you are describing how a lisp programmer would expect things to work. As my comment was saying, I was exploring whether a verbatim translation of C syntax works as sexeps, and where it fails.