On Sep 14, 2015, at 6:16 PM, John Carmack <jo...@oculus.com> wrote: > Is there a deep reason why defines aren’t allowed in the branches of an if, > but are for cond / while / unless? > > Wrapping code in (let() …) instead of (begin …) works fine, but it is a > strange quirk to explain to someone else.
It exposes our history. Traditionally there are no extra markers in LISP-style syntax to introduce phrases within a grammatical sentence. Thus, an if-expression obeys the grammar (if test-expression then-expression else-expression) not an Algol-style variant with additional keywords: (if test-expression #:then then-expression #:else else-expression) If we had those markers (not just in if-expressions but wherever we may allow sequences of expressions), we could mixin definitions wherever we wanted. In cond, it is obvious which phrase is a branch (due to the parentheses/brackets) and that the first part of each branch is a test-expression. The extra pair of parens play the role of Algol-style markers. Now, if Racket had emerged as an alternative attempt to address all of Lisp's weaknesses, we might have overcome this problem, too. But Racket grew organically and we value backward compatibility very highly for our programmers. You might say we are the C++ of the LISP world, but I hope we can do better in the long run. -- Matthias -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.