develooper Front page | perl.perl5.porters | Postings from August 2019

macros v. inline functions

Thread Next
From:
hv
Date:
August 12, 2019 11:34
Subject:
macros v. inline functions
Message ID:
201908120955.x7C9tVP06767@crypt.org
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.

Hugo

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About