Comment on Macros in Perl6parentComments−draegtun14yIt also begs the question 'Why not use a function?', i.e. it is not a case where one needs a macroThe (last) example is best being a macro because it avoids running that crazily-expensive-computation() whereas a function would evaluate it.−Xurinos14yThe argument on the delayed execution issue is that you could just wrap crazily-expensive-computation() in a lambda/sub that is executed conditionally.−draegtun14yIndeed. However I do like the fact that Perl6 macros & functions use the same calling syntax and so are often interchangeable.
Comments
It also begs the question 'Why not use a function?', i.e. it is not a case where one needs a macro
The (last) example is best being a macro because it avoids running that crazily-expensive-computation() whereas a function would evaluate it.
The argument on the delayed execution issue is that you could just wrap crazily-expensive-computation() in a lambda/sub that is executed conditionally.
Indeed. However I do like the fact that Perl6 macros & functions use the same calling syntax and so are often interchangeable.