by emfle · 18y ago · 0 comments
No wait: on second thought, I surrender to how completely dumbfounded I am by this comment.
I'm calling Kenny...
Perhaps what you mean is that when a construct is unfamiliar to a programmer then they have to think harder about how to use it?
No, I don't mean unfamiliar. Things like parentheses and prefix notation are unfamiliar to many people, but once learned, they don't require much more cognitive processing than other notation. There are several things in Java that are similarly weird until you learn them.
You don't have to think about how the macro is written or what it's expanding into when you use it, you just have to know the semantics of the macro. "When I pass such and such, it will produce code that evaluates this in that way". Similar to a function or a language primitive right? If you're writing a for loop in Java, do you have to care how it's implemented in the JVM?!
As for writing macros: you're writing a function that takes an AST and returns an AST to use as replacement. This function will be called at compile-time to change your nice high-level macro call into lower-level code. There are a couple pitfalls (variable capture, multiple evaluation) but they're always the same and you'll learn about them quickly enough that it will become a sixth sense.
Or the performance characteristics of that library.
Or the fencepost cases of a loop.
Or which exceptions to handle.
...