[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 21:29:08 -0400, John Boyle  
<johnthescavenger@x> wrote:

> While all Schemes I've tested
> that support define-syntax do allow redefinition of "if"... on Racket, it
> does not play well with low-level macros (using datum->syntax, or the
> "mzlib/defmacro" library) due to their phase-separation.  Ikarus does do
> exactly what I want (I can redefine "if" and define low-level macros with
> it); Chicken... does provide defmacro, in a separately downloadable  
> library
> I found just now, which does work the way I want; Chibi and scsh/scheme48
> don't seem to have low-level macros, while Gambit doesn't even have
> define-syntax.
>
> I suppose this committee qua Scheme committee isn't responsible for  
> Common
> Lisps, or technically even Racket.  Restricting my view to the other
> Schemes, they do seem to universally allow redefinition of built-in
> operators without breaking everything, unlike the Common Lisps (and emacs
> lisp).  Clearly this is a good feature in this case, though I don't  
> believe
> the standard guarantees it, and I wonder whether it'll be different for  
> new
> Schemes or whether existing Schemes will change.  Meanwhile, I'll  
> continue
> using Racket as a compilation target and runtime.

This is very surprising to me. I do not think I understand what your exact  
troubles are. I take it as a given that you would implement your new IF  
form as a hygienically safe macro, whether that is achieved by using  
something like SYNTAX-CASE or by using SYNTAX-RULES. Assuming that the  
macro is hygienic, any R6RS Scheme supports the use of the new IF macro in  
whatever other macro you want to use it in, and also in normal code. In  
other words, there should be literally no way to distinguish the new IF  
 from the old one. For example, assuming that you have a library (scheme)  
that holds all of your normal Scheme environment, it is trivial to replace  
(scheme) with (scheme-extended-if); all other code should simply work, and  
your new IF form should work exactly as if it were already built that way.

(library (scheme-extended-if)
   (export <bindings of (scheme)>)
   (import (rename (scheme) if %if))
   (define-syntax if
     (syntax-rules ()
       [(_) (void)]
       [(_ test cons rest ...) (%if test cons (if rest ...))])))

After that, things just work, you cannot tell the difference between the  
built-in and the current in practice.

-- 
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