New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
context consistency for overloaded operators #16274
Comments
From zefram@fysh.orgCreated by zefram@fysh.orgShould context be passed through when operators invoke overloaded methods? $ perl -lwe 'package Foo { use overload "!" => sub { print wantarray ? "list" : defined(wantarray) ? "scalar" : "void"; "foo" }; } $f = bless({}, "Foo"); $a = !$f; @a = (!$f); !$f' It's not consistent. Void context is passed through, but the method We should not make list context be propagated. The purpose of overloading The purpose of overloading is to allow an object to provide behaviour Note that we have no need to propagate void context for the purpose Perl Info
|
From @KES777
Because operators implemented as subroutines this subroutines should know the context they are called.
# https://perldoc.perl.org/perlop.html#Logical-Defined-Or Also without context propagation we will not be able to implement sets multiplication: @multi = @z * @y; |
The RT System itself - Status changed from 'new' to 'open' |
Migrated from rt.perl.org#132490 (status was 'open')
Searchable as RT132490$
The text was updated successfully, but these errors were encountered: