develooper Front page | perl.perl5.porters | Postings from April 2018

Re: [perl #133109] push on scalar forbidden: why?

Thread Previous | Thread Next
Dave Mitchell
April 21, 2018 19:57
Re: [perl #133109] push on scalar forbidden: why?
Message ID:
On Sat, Apr 21, 2018 at 06:17:09PM +0100, Philip R Brenan wrote:
> *Push gets its array either directly or via a reference. *In this example:
> push $r, 3
> would affect only $r, not @real_a,  because no  array dereference would be
> implied or performed.

Then you've just broken overloading. For example, suppose someone writes
this innocuous  method:

    sub push_foo {
        my ($self, $array_ref) = @_;
        push $array_ref, $self->foo;

this method works exactly as documented and expected, until the day
someone passes an overloaded scalar as an arg to it, then finds that
the overloading is being quietly ignored.

That he said that that that that is is is debatable, is debatable.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About