[racket] Pattern matching define macro

From: Brian Adkins (racketusers at lojic.com)
Date: Sat Jul 12 18:49:25 EDT 2014

On Jul 12, 2014, at 6:17 PM, Asumu Takikawa wrote:

> On 2014-07-12 16:18:55 -0400, Brian Adkins wrote:
>> 1) It's odd to me to specify the l argument, and then never refer to it.
>> 2) The syntax of the former seems less "noisy".
> 
> I agree that the syntax can be noisy for simple cases.
> 
> The design rationale for having the header is to allow optional,
> keyword, and rest arguments. Also it lets you avoid using an `and`
> pattern to refer to the whole argument.
> 
> Just wanted to note that in case you or anyone else was wondering why
> the seemingly redundant header is there.
> 
> Cheers,
> Asumu

In hindsight, I was probably being overzealous in trying to get rid of everything I didn't need for my simple example. Being able to reference the original argument will certainly be needed at times, and a couple extra [ ] chars is really not that big of a deal. Plus the advantage of someone else being able to look at my code and immediately understand define/match vs. some ad-hoc macro I whipped up is significant.

As I mentioned in another reply, I quickly ran into a limitation with my macro that I wouldn't have if I had used define/match. I'll wait until I have enough code to see what the real pain points might be.

Posted on the users mailing list.