[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



I see, that does work to define "if".  (Racket, under #lang r6rs, only allows one "library" form, so I can't run all of the above directly without maybe creating separate files and figuring out how to load them... --which I just did.)  Ok, your example works.

Is there a portable way within R6RS to effectively or actually turn off the explicit phasing when it exists?  Imagine I want to do this for a large tree of macros.  Is there a better approach than, say, creating a new library for each new macro?
--John Boyle
Science is what we understand well enough to explain to a computer. Art is everything else we do. --Knuth



On Thu, Oct 11, 2012 at 8:55 PM, Aaron W. Hsu <arcfide@x> wrote:
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
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports