[racket] a little macro exercise

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Sat Oct 9 00:20:02 EDT 2010

Alright, here's the version with no mutation:

(define-syntax-rule (cas-cad-e e [(n ...) code ...] ...)
  (let/ec esc
    (syntax-parameterize
     ([break (make-rename-transformer #'esc)])
     (let*-values
         ([(tmp) e]
          [(earlier? ret) (values #f (void))]
          [(earlier? ret)
           (if (or earlier? (equal? tmp n) ...)
               (values #t (begin code ...))
               (values earlier? ret))]
          ...)
       ret))))

On Fri, Oct 8, 2010 at 10:09 PM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
> Mutation that is invisible to the user is fine by me.
>
> Jay
>
> Sent from my iPhone
>
> On Oct 8, 2010, at 10:04 PM, Neil Van Dyke <neil at neilvandyke.org> wrote:
>
>> Jay McCarthy wrote at 10/08/2010 11:41 PM:
>>> I wrote mine without looking at Elis. I like his and mine better than the others. And obvs I like mine more. =P
>>>
>>
>> Mutation?! :)
>>
>> I suppose that these different solutions might hint at some of our varying styles or priorities.
>>
>> My use of "syntax-rules" was done as an exercise, or I probably would've used newer features and been more readable.  But, as a matter of current personal style, I still would've tried to avoid redundant tests and mutations in the generated code.
>>
>> --
>> http://www.neilvandyke.org/
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.