News for hackers. Stuff that matters.
Re:Making Macros in CoffeeScript by boucher on Sunday June 26, 2011 @01:40PM (#2698506)
Pretty cool. We've been using macros in the Cappuccino source code for years, but we were too lazy to write our own macro processor so we just use the GCC preprocessor. Relying on GCC being available turns out to work pretty well.
Re:Making Macros in CoffeeScript by __rkaup__ on Sunday June 26, 2011 @01:42PM (#2698511)
Didn't know the GCC preprocessor was language agnostic. Never thought about it really.
Re:Making Macros in CoffeeScript by saurik on Monday June 27, 2011 @05:02AM (#2700653)
You actually can/will run into problems if the language you are pre-processing with CPP tokenizes differently than C.
Re:Making Macros in CoffeeScript by rimantas on Sunday June 26, 2011 @01:02PM (#2698414)
Swap was not the best choice to be used as example, imho. CoffeScript has deconstructing assignments so to swap two variables you just do [x, y] = [y, x].
Re:Making Macros in CoffeeScript by danking00 on Sunday June 26, 2011 @01:26PM (#2698477)
I saw parsec-coffee-script a while back and really wanted to help, but I was quite busy. I'd love to see hygenic macros in coffee-script... Unfortunately, it looks like parsec hasn't been committed to since February. Anyone know what the status of that project is?
Re:Making Macros in CoffeeScript by yason on Sunday June 26, 2011 @02:33PM (#2698678)
Isn't this just lexical macros?

I expected a HN headline to refer at least to a novel Lisp style AST macro implementation; there's m4 and cpp for basic textual macro expansion and those are very old news.

Re:Making Macros in CoffeeScript by davidpadbury on Sunday June 26, 2011 @06:59PM (#2699377)
It's actually working on the CoffeeScript AST. Admittedly the example I used doesn't demonstrate this particularly well.