p5h / p5summit-2019

Perl 5 Summit
0 stars 0 forks source link

Inline vs macros #20

Open toddr opened 4 years ago

toddr commented 4 years ago

Proposed by Hugo @hvds

leonerd commented 4 years ago

An excellent argument in favour of inline functions over macros is that it avoids such stupid bugs as the always-wrong SvTRUE(POPs) bug that I wasted about an hour on today:

https://github.com/Perl/perl5/pull/17212#discussion_r339315113

leonerd commented 4 years ago

Update: Turns out you also can't use SvTRUEx(POPs) either because on non-GNUC compilers that has to use the PL_sv global temporary and that doesn't play nicely on threads. So we must use

{
  SV *tmp = POPs;
  ret = SvTRUE(tmp);
}

which would all just go away if we could define SvTRUE as a function instead as ret = SvTRUE(POPs)