- Joined
- Oct 19, 2023
it's sort of likeI was indeed under the impression you should always default to functions and then switch to macros upon noticing niggerlicious DRY code smells.
void*
; if you use it in the right places you can get around a bunch of stupid bullshit, but if you abuse it you will make incomprehensible spaghettilisp macros give you the power to add an additional feature to the language so you must carefully judge whether you really need the increased complexity
stuff likeI have yet to find a problem that could be solved by macros that could not be solved by simpler means, usually a closure, albeit only in languages with first class functions.
Is there really a scenario in which macros are the best solution?
cond
is sometimes a macro that compiles to if
generally the only way to create new control structures is with macros
they also work pretty well for weird things like forcing stuff to inline and creating 11 slightly different versions of the same definition
you could also make a macro that takes some shit like
(select (from 'users) (where (eq 'username some-variable)))
and it compiles to properly prepared sql boilerplate or whatever you need it to doyou can really use them for whatever you want but the most basic use is to make keywords that stand for large chunks of boilerplate
there is also the infamous loop macro as well...
a big problem with macros is that most of the really good macros are already defined so you never end up thinking about them