macros v. inline functions

This may be a topic worth considering at "the upcoming Perl 5 Core Hackathon".

It would be useful to have guidelines for when we should prefer to add
inline functions rather than macros.

I suspect we could be using them a lot more than we do, but I don't know
how many platforms still have insufficient capabilities to support them.

Macros suffer from lack of types on arguments, risk of multiple evaluation,
and opacity in debuggers. They also do not give compilers a choice whether
to inline them, so may lead to less efficient code.

Inline functions cannot do everything macros can, but where they can do
what is needed the only drawback I know of is that on a platform that
does not support them you'll get much less efficient code.

8/12/2019 9:55:31 AM
perl.perl5.porters 47752 articles. 1 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 48