[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] Formal Response #382: Allow "if" to accept arbitrarily many if-then pairs

On Thu, 11 Oct 2012 22:21:05 -0400, John Boyle  
<johnthescavenger@x> wrote:

> Aaron, I can't get your example to run.

Sorry, that was a quick one-off and not intended to be runnable (the  
export list is completely
invalid for one). Here's an example that you can actually cut and paste as  
a series of libraries.

(library (extended-if)
   (export if)
   (import (rename (rnrs) (if %if)))
   (define-syntax if
     (syntax-rules ()
       [(_)           (%if #f #t)]
       [(_ t c r ...) (%if t c (if r ...))])))
(library (example)
   (export result)
   (import (except (rnrs) if) (for (extended-if) run expand))
   (define-syntax test
     (lambda (x)
       (let ([x (cadr (syntax->datum x))])
         (if x 42 (not x) 24))))
   (define result (list (test #t) (test #f))))

Notice that you only need the explicit FOR when you are dealing with  
explicit phasing systems like Racket. On systems like Chez or  
Vicare/Ikarus, you should be able to just specify the (extended-if)  
library and have things work.

Aaron W. Hsu | arcfide@x | http://www.sacrideo.us
Programming is just another word for the Lost Art of Thinking.

Scheme-reports mailing list