[racket-dev] syntax parsing: must be a nice pattern-y way to do this

From: John Clements (clements at brinckerhoff.org)
Date: Mon Sep 17 14:31:07 EDT 2012

On Sep 17, 2012, at 11:27 AM, Ryan Culpepper wrote:

> On 09/17/2012 02:20 PM, John Clements wrote:
>> 
>> On Sep 16, 2012, at 5:48 PM, Ryan Culpepper wrote:
>> 
>>> See 'define-template-metafunction' in syntax/parse/experimental/template. Remember to change the relevant occurrences of 'syntax' to 'template'.
>> 
>> Neat!
>> 
>> I'm guessing, though, that I probably shouldn't release planet packages that depend on experimental-mumble…
> 
> I think it's fine if you're prepared to update the package when it changes. If I do remove syntax/parse/experimental/template, I'll mark it as deprecated for a release cycle or two first.

I'm still not quite sold. In particular, I have students writing code against this planet package, and I've just recently had a situation where a student wanted to run his old code, and I was happy to be able to tell him to qualify his planet reference so as to avoid having to update his code; relying on a feature that later disappears reduces the chance that students will be able to run their code as-is three years from now. 

I really don't mean to be persnickety, here: another motivation is that I've already bitten the bullet and written the code that doesn't require define-template-metafunction :).


John

> 
> Ryan
> 
> 
>>> On 09/16/2012 08:31 PM, John Clements wrote:
>>>> I want to apply a transformation to a nested pattern element.
>>>> 
>>>> To start with, suppose I have a (kind of useless) with-handlers that looks like this:
>>>> 
>>>> (with-syntax
>>>>          ([((arg ...) ...)
>>>>            #`((clause.input ...) ...)])
>>>>        et-cetera)
>>>> 
>>>> That is, I've basically just renamed "clause.input" to "arg".
>>>> 
>>>> But now, I want to perform some transformation on the elements. I'd like to write this:
>>>> 
>>>> (with-syntax
>>>>          ([((arg ...) ...)
>>>>            #`((#,(transform #'clause.input) ...) ...)])
>>>>        et-cetera)
>>>> 
>>>> .. but this fails, with the error "new-style-signals.rkt:42:30: syntax: missing ellipsis with pattern variable in template in: clause.input"
>>>> 
>>>> I can certainly work around this, by abandoning the pattern-matching slickness and just using a bunch of syntax->lists, but it seems like there must be a nicer way. Am I missing some nifty trick?
>>>> 
>>>> John
>>>> 
>>>> 
>>>> 
>>>> 
>>>> _________________________
>>>>   Racket Developers list:
>>>>   http://lists.racket-lang.org/dev
>>>> 
>>> 
>> 
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4800 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20120917/875685b2/attachment.p7s>

Posted on the dev mailing list.