Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> If you've ever cursed the error messages from a C++ compiler, think how much worse it would be if that compiler was written by your co-worker part-time as a side effect of writing rest of the code.

This is why you use proper facilities to write macros, that will enable you to forge better error messages than most C compilers. This is also why you don't simply use something like `defmacro` that will not let you supply syntactic information (syntax objects) with location and context information.

A good macro has a contract that constrains its use and inform you when you're breaking it, so that you don't have to rely on your coworkers to explain their macro to you.

See this[0][1] for a very detailed view on how you can provide the programmer with the tools they need to create abstractions that stretch well into the world of macros and still be able to make them usable.

You can set enforcable conditions for your macros to guide people, just like any language can statically check their syntax.

This is not an unsolved problem. What is unsolved, like many people have mentioned, is when the culture of a language (and the facilities of lesser languages) don't emphasize managing macros like other abstractions.

Using Lisps that don't emphasize more than "Macros are functions that modify lists of syntax at read time" will lead people to believe that's all there is to it. You won't have to be angry about macros if you use a language that gives people the tools to help you use them and then fosters that idea.

0 - http://docs.racket-lang.org/syntax/Parsing_Syntax.html?q=syn...

1 - http://docs.racket-lang.org/syntax/stxparse-specifying.html?...



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: