Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why drop macros as much as possible? [closed]

Tags:

macros

clojure

What's the deal with not doing macros ? or what's the deal with trying to avoid macros ?

I've seen some posts recently telling to slow down on the use of macros: DSL!=macros, re-writing code with functions instead of macros, the begin of a study to switch from macros to functions...

but what's the deal ? you think macros will rule the world and you don't want that ?

What is wrong with macros? why lower their usage ? aren't they supposed to be a method to extend the language ?

like image 272
Belun Avatar asked Dec 09 '22 13:12

Belun


1 Answers

The main argument I see for preferring function to macros is that they aren't available as first class functions at run time, which limits your flexibility to use various powerful functional programming techniques.

Personally I think macros are still an extremely useful programming tool providing you use them appropriately - i.e. enabling you to do complex code transformations at compile time that would otherwise incur high runtime costs or require a lot of unnecessary boilerplate code.

like image 135
mikera Avatar answered Dec 22 '22 13:12

mikera