[r6rs-discuss] Expansion order [was: Now, where were we?]
Sam TH
samth at ccs.neu.edu
Wed Feb 25 10:21:55 EST 2009
On Wed, Feb 25, 2009 at 10:03 AM, Andre van Tonder <andre at het.brown.edu> wrote:
> On Tue, 24 Feb 2009, Sam TH wrote:
>
>> On Tue, Feb 24, 2009 at 6:03 PM, John Cowan <cowan at ccil.org> wrote:
>>>
>>> Tangent: Can someone explain to me what the merit is in being able to
>>> reference macros before they are defined in *any* context? Perhaps there
>>> is one, but I don't see it.
>>
>> If you define a macro to that simulates a value definition form with a
>> macro definition form (this is what my `define-inline' example does,
>> using `syntax-rules'), then you would probably want to have mutual
>> recursion among these definitions be possible.
>>
>> This might be a bit of expressiveness in the macro system that could
>> be given up at the REPL, though.
>
> Well, not that much expressiveness. You can fix your example
More interesting examples can be constructed. For example, using the
PLT contract system:
(define/contract (even? x)
(-> number? boolean?)
(or (zero? x) (odd? (sub1 x))))
(define/contract (odd? x)
(-> number? boolean?)
(and (not (zero? x)) (even? (sub1 x))))
this involves defining `odd?' and `even?' as macros, and referring to
`odd?' before its definition. However, as I said, this may be a
perfectly reasonable bit of expressiveness that's not needed at the
REPL, although I'd like to have it available in libraries.
--
sam th
samth at ccs.neu.edu
More information about the r6rs-discuss
mailing list