> On Jun 2, 2019, at 7:13 PM, Matthias Felleisen <matth...@felleisen.org> wrote:
> 
> 
> 
>> On Jun 2, 2019, at 9:41 PM, Kevin Forchione <lyss...@gmail.com 
>> <mailto:lyss...@gmail.com>> wrote:
>> 
>> Hi guys,
>> I’ve been working with macros and let/cc and have a situation where I have 
>> the 2nd macro bound to the let/cc return of the first. No idea how I’d do 
>> that, but here’s an example of what I’m attempting to do:
>> 
>> #lang racket
>> 
>> (require (for-syntax racket/syntax))
>> 
>> (define-syntax (fn stx)
>>  (syntax-case stx ()
>>    [(_ (arg ...) body0 body ...)
>>     (with-syntax ([return (format-id #'body0 "~a" #'return)])
>>       #'(λ (arg ...) (let/cc return body0 body ...)))]))
>> 
>> (define-syntax (false stx)
>>  (syntax-case stx ()
>>    [(_) #'(return #f)]))
>> 
>> ((fn (x y) (when (< x y) (return x)) y) 2 30) ; => 2
>> ((fn (x y) (when (< x y) (false)) y) 2 30)   ;=> #f
>> 
>> My thought is that the 2nd macro doesn’t know about the 1st macro except 
>> perhaps through the six of compile time… so that if I had define-syntax 
>> working with a lambda I’d have all the pieces available in the (fn …) but 
>> not sure what tools I might use to accomplish that.
>> 
>> Any ideas are appreciated!
>  
> 
> This situation calls for syntax-parameters in my mind: see docs, too — 
> Matthias

Hmmm. A cursory glance at some of the examples suggests I’ll have to do some 
exploring on this. One issue that it looks like I’ll have to work out is that 
“false” in my example needs to translate to “(return #f)” and I’m not sure at 
this stage where a syntax-parameterize statement would be positioned in the fn 
macro (or how it would know to use it unless it could interrogate the body list 
looking for that value. That might be what I’d need to do here…

Kevin

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/C4425B12-9C1F-4159-B4BA-D09C89419CB9%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to