Macros vs Functions
Okay, I'm sure this has been asked before but I'll be damned if I can find it in either the wiki or the Forum (a google search looked promising [ http://www.fredshack.com/docs/nsis.html ]but the author of the page ultimately did not address the issue).
So, here goes.
Macros vs Functions
The basic question: when to use what, and why?
The more involved question: pros and cons to each? (likely to be part of 'why')
Now I can think of a couple off the top of my head, I'll just list the presumable pros (assume them to be cons for the opposite)
Macros: you can 'sorta' pass them parameters as you would in most scripting languages:
!macro parm1 parm2 parm3
something with ${parm1} ${parm2} ${parm3}
!macroend
Macros: run faster?
Now this one is a contentious one. In many languages, macros execute faster than functions. Does this hold true for NSIS, and does it really matter?
Functions: no code duplication
Macros insert the same code whereever !insertmacro is used, so the actual code is likely to be duplicated and make for a larger installer; though it's not likely to matter?
Functions: no worrying about goto labels
Many macros using a goto require labels to be uniqueified by manner of ${__LINE__} as otherwise labels may be duplicated. Even if it doesn't get used twice within the same section, the name of the label should be uniqueified as a basic label such as "loop" may already exist in the section the macro is inserted into. In a function, there is no such worry.
Macros & Functions: stack manipulation
it seems that both macros and functions require stack manipulation if you want to use variables - otherwise you may overwrite variable values from before the !insertmacro / before the !call .
I'm tempted as it is to make most of my macros functions with macro front-ends - e.g. have the main body of code be the Function, while using the macro to push elements to the stack, with those elements coming from the parameter passing. But given that I don't know the full Macros vs Functions story, I'm not sure if that will come bite me in the behind further down the road.
If there is indeed a wiki on this already, please point me to it. If there is a thread on it, please point me to it - and I'd be happy to turn it into a wiki page. If it's all just tiny tidbits scattered about, people - like myself - are never going to find them all to get a good grasp on macros vs functions.