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

Not quite. I wasn't clear enough. These operations are purely UI manipulations. They don't operate on lists of values or even need to know what they are. What they care about are things like: should I set a width property or a height property? To which you might reply: fine, just pass the dimension around and have a set-size function that knows whether to set width or height depending on the dimension, and so on. I say: yeah, you can do it that way, but it takes more code and is harder to read, because now you have to write it in a dimension-agnostic way, which is not how humans (or I at least) like to think about these things. It's easier to write or read the concrete version for one dimension and then say "the other dimension is just like this only transposed", which is exactly what the macro does for us.

Do you need macros to make such a program work? No. Can you use them to make the program shorter, clearer, and more generalizable? Yes.



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

Search: