This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
propagate context into overloads [perl #47119]
authorJesse Luehrs <doy@tozt.net>
Wed, 27 Jun 2012 02:12:18 +0000 (21:12 -0500)
committerJesse Luehrs <doy@tozt.net>
Thu, 28 Jun 2012 08:06:08 +0000 (03:06 -0500)
commit67288365cab33e76a48b697c001c11d4dc5b1912
tree8d612e9bb96382ad1b99581ae81e4f2a7356828b
parent591097e07a9ddfd1783a99ea394ab7e4113242b3
propagate context into overloads [perl #47119]

amagic_call now does its best to propagate the operator's context into
the overload callback. It's not always possible - for instance,
dereferencing and stringify/boolify/numify always have to return a
value, even if it's not used, due to the way the overload callback works
in those cases - but the majority of cases should now work. In
particular, overloading <> to handle list context properly is now
possible.

For backcompat reasons (amagic_call and friends are technically public
api functions), list context will not be propagated unless specifically
requested via the AMGf_want_list flag. If this is passed, and the
operator is called in list context, amagic_call returns an AV* holding
all of the returned values instead of an SV*. Void context always
results in amagic_call returning &PL_sv_undef.
gv.c
lib/overload.pm
lib/overload.t
pp.h
pp_hot.c
pp_sys.c