Up with a horrible ear-ache this morning I decided to include a FizzBuzz example in Heresy, the Racket #lang I've been working on, and ran into an unexpected behavior in the (case ...) statement.
In many languages with case, you can make the testing value a constant, and then make the matching clauses actual calculations which then match against that constant. So when doing FizzBuzz in C-like languages you can do something like "switch 0" and then "case x % 3" for the matching clauses. It turns out this doesn't work in Racket, because Racket quotes the values in the matching clauses so they do not evaluate. Specifically, it narrows down to doing this in (case/sequential-test ...): #`(equal? v 'k) I can implement an alternate version that works as I expect (and will probably include it in Heresy) just by removing that quote in my version, but I was curious as to the reasoning behind this behavior and if perhaps there's some explanation for it that I may've missed. Any insights appreciated, John Berry
____________________ Racket Users list: http://lists.racket-lang.org/users