Aaron, I can't get your example to run.  Pasted directly into DrRacket, and
with #lang r6rs at the top:

#lang r6rs

(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 ...))])))

=>
import: bad `rename' form in: (rename (scheme) if %if)

I think the (old-name new-name) pairs are supposed to be paired with
parentheses, so replacing the rename form with:
(rename (scheme) (if %if))
and running again, yields:

module: identifier already imported from a different source in:
  #%app
  (rename (lib "scheme/main.rkt") #%app #%app)
  r6rs/private/prelims

This same error message happens even when the program is pared down to:

#lang r6rs

(library (scheme-extended-if)
   (export <bindings of (scheme)>)
   (import (scheme)))

=>
module: identifier already imported from a different source in:
  #%app
  (lib "scheme/main.rkt")
  r6rs/private/prelims


So I suspect this is either an error in Racket's R6RS or an error in your
suggested code.
--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 6:46 PM, Aaron W. Hsu <[email protected]> wrote:

> On Thu, 11 Oct 2012 21:29:08 -0400, John Boyle
> <[email protected]> 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 | [email protected] | http://www.sacrideo.us
> Programming is just another word for the Lost Art of Thinking.
>
> _______________________________________________
> Scheme-reports mailing list
> [email protected]
> http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports
>
_______________________________________________
Scheme-reports mailing list
[email protected]
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports

Reply via email to