On Wed, Feb 25, 2009 at 10:03 AM, Andre van Tonder <[email protected]> wrote:
> On Tue, 24 Feb 2009, Sam TH wrote:
>
>> On Tue, Feb 24, 2009 at 6:03 PM, John Cowan <[email protected]> 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
[email protected]

_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to