Re: [racket-users] composing unquote-rewriters in redex?

2015-08-23 Thread Robby Findler
Would it work to have your code expand into uses of
with-unquote-rewriter that chained things together?

Alternatively, I wouldn't mind if something like that were folded into
Redex itself and with-unquote-rewriters left as part of the public API
for backwards compatibility reasons.

And one other thought: I generally have discouraged the use of unquote
rewriters in favor of writing little meta-functions (whose body uses
unquote) and then using compound rewriters to adjust the metafunction
calls. Does that work well in your use cases?

Robby


On Sun, Aug 23, 2015 at 5:27 PM, Matias Eyzaguirre  wrote:
> To get rid of racket expressions that have been embedded in metafunctions and 
> reduction relations, you use `with-unquote-rewriter`, but you can currently 
> only have one rewriter active at a time (as underneath it's a single 
> parameter that holds a function).
>
> I've been writing a little library to make working with rewriters a little 
> more friendly, I expose a rewriter stack that you can push and pop atomic and 
> compound rewriters to. I've been thinking about how best to add support for 
> unquote rewriters, but I'm stumped.
>
> One possibility that occurred to me was to have pushing an unquote rewriter 
> procedure RW onto the stack just set the current unquote rewriter to a 
> function that calls RW on the lw in question, and if RW produces an lw where 
> the unq? field is true, then that is the result, otherwise use the previous 
> unquote rewriter (thus rewriters that don't want to make a change pass 
> responsibility up the stack). Other than the fact that this could get rather 
> slow when the unquote-rewriter stack gets really deep, redex currently 
> doesn't publicly export the current-unquote-rewriter parameter. Would it be 
> possible to make that change?
>
> In the meantime I suppose I shall make my own parameter for keeping track of 
> unquote-rewriters, though this has the disadvantage of not knowing anything 
> about unquote-rewriters set with the with-unquote-rewriter macro.
>
> Another thought that would require more effort, why is there only ever a 
> single unquote-rewriter at a time? compound-rewriters and atomic-rewriters 
> both have a table, allowing multiple rewriters to be layered on top of each 
> other?
>
> Anyway thanks,
> Matias Eyzagurre.
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] composing unquote-rewriters in redex?

2015-08-23 Thread Matias Eyzaguirre
To get rid of racket expressions that have been embedded in metafunctions and 
reduction relations, you use `with-unquote-rewriter`, but you can currently 
only have one rewriter active at a time (as underneath it's a single parameter 
that holds a function).

I've been writing a little library to make working with rewriters a little more 
friendly, I expose a rewriter stack that you can push and pop atomic and 
compound rewriters to. I've been thinking about how best to add support for 
unquote rewriters, but I'm stumped.

One possibility that occurred to me was to have pushing an unquote rewriter 
procedure RW onto the stack just set the current unquote rewriter to a function 
that calls RW on the lw in question, and if RW produces an lw where the unq? 
field is true, then that is the result, otherwise use the previous unquote 
rewriter (thus rewriters that don't want to make a change pass responsibility 
up the stack). Other than the fact that this could get rather slow when the 
unquote-rewriter stack gets really deep, redex currently doesn't publicly 
export the current-unquote-rewriter parameter. Would it be possible to make 
that change?

In the meantime I suppose I shall make my own parameter for keeping track of 
unquote-rewriters, though this has the disadvantage of not knowing anything 
about unquote-rewriters set with the with-unquote-rewriter macro.

Another thought that would require more effort, why is there only ever a single 
unquote-rewriter at a time? compound-rewriters and atomic-rewriters both have a 
table, allowing multiple rewriters to be layered on top of each other?

Anyway thanks,
Matias Eyzagurre.

-- 
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.
For more options, visit https://groups.google.com/d/optout.