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

Re: [Scheme-reports] ANN: first draft of R7RS small language available



On Thu, 21 Apr 2011, Alex Shinn wrote:

> The Chibi algorithm is a little unusual, and I may need to
> change it depending on what we do with the standard, but
> I happen to like it a lot.  Whereas in Chez all identifiers are
> effectively bound in the top-level (whether they really are or
> not), in Chibi all identifiers are effectively _unbound_ at the
> top-level.  This means you can import multiple macros using
> the same keywords and not have to rename them, whether
> the keywords are bound or not - it just works.
>
> The option of _not_ renaming I consider to be far more
> important than the ability to rename.  I had honestly never
> considered that you might want to rename deliberately, and
> I see now that might have uses, but it seems the most
> common use will be to avoid conflicts from macros using
> the same keywords.  There are many macros out there
> using common keywords like ":" and "<=", and it's a real
> pain not to be able to use them together without renaming
> one.  You have to keep in mind all the renamings as you
> look at the code, and can't cut&paste examples.

You can use them together.

The way we got around this in the past is simply to share
the same keyword binding between macros, for example

   (module (base)
    (export => cond ....)

    (define-syntax => error-message)
    (define-syntax cond ......))

   (module (reuse-=>)
     (import (base))   ; IMPORTS => binding FROM (base)
     (export =>        ; REEXPORTS => binding
             macro-using=>as-keyword)

     (define-syntax macro-using=>as-keyword
       (syntax-rules (=>)      ; REFERS TO SAME => AS COND IN BASE
         .......)))

   (module (example)
     (import (base)      ; IMPORTS => BINDING
             (reuse=>))  ; REIMPORTS SAME => BINDING

     ; NOW BOTH COND AND MACRO-USING=>AS-KEYWORD WORK WITH SAME =>)

So we have defined two macros using the same BOUND keyword => in different 
modules and you can easily use them together.  We didn;t have to do anything 
special.

Andre

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