(no title)
disnet | 13 years ago
The description page (like the rest of the project at them moment) is definitely a work in process. Sorry about the confusion!
> 'Wish the function keyword in JavaScript wasn't so long? What if you could define functions with def instead?'
> Erh, no? Why in the lord's name would I ? Is that your big selling point? 'I don't like function() because it's too long?'
This is just a really basic example of what you can do. Obviously you could have the same effect with sed but we need something simple to shows what basic macro definitions look like.
> 'Want a better way to make "classy" objects?'
> <provides example that looks like php vomited on Javascript after mating with ruby>
I'm assuming you refer to the macro definition with $ and whatnot. If you have ideas for better syntax please contribute! The notation is by no means final. That said I think it's pretty good for what it needs to do, matching syntax patterns and transforming them into new bits of syntax. Certainly more readable than a full parser/compiler.
> Am I the only one that doesnt understand the use case of this? Or is it just another lexer/parser?
The idea is to provide a middle way between no syntax extensions and writing your own full compile-to-js language languages like CoffeeScript which allow you to add any kind of syntax you want, but at the expense of being able to compose extensions. If you like the class notation of CS you must buy into all the syntax choices of CS whereas macros allow you to add just the syntax you want.
Whether you want new syntax is of course a different question. Other languages like scheme and closjure have found macros useful so sweet.js is an experiment to find out if the same syntactic extensibility that they provide is useful in JavaScript.
Hope that helps!
SchizoDuckie|13 years ago
How about a more clear description like above on your page with some readups into macro's, and some more complicated examples that tell me as a programmer: "Yes, I dó need macro's!" and I can use them for these and these cases?
Also, don't underestimate how smart your audience is going to be by giving them just 3-line examples. I always find it more clear when there's some actual use cases on the wiki pages. How about a proper class, or a todoMVC style demo, so that people can actually imagine what kind of possibilities this would unlock?