develooper Front page | perl.perl5.porters | Postings from June 2013

[perl #118513] Changed behaviour in UNIVERSAL::can

Thread Previous
Father Chrysostomos via RT
June 17, 2013 15:25
[perl #118513] Changed behaviour in UNIVERSAL::can
Message ID:
On Mon Jun 17 06:38:19 2013, wrote:
> UNIVERSAL::can's behaviour has changed between perl 5.16.3 and perl
> 5.18.0 in how it treats classes that have never been seen before.
> This code:
> #!/bin/sh
> perl -E 'say ">".UNIVERSAL::can("Foo", "can")'
> perl -E 'say ">".Foo->can("can")'
> perl -E 'package Foo;package main;say ">".UNIVERSAL::can("Foo", "can")'
> perl -E 'package Foo;package main;say ">".Foo->can("can")'
> does the following with perl 5.16.3:
> >
> >
> >CODE(0x19e0e58)
> >CODE(0xa60e58)
> and this with 5.18.0:
> >CODE(0x248b090)
> >CODE(0x2135090)
> >CODE(0x1cd5090)
> >CODE(0x145d090)
> As you can see, UNIVERSAL::can("Foo", "can") and Foo->can("can") only
> return a sub-ref in 5.16.3 if the Foo package has already been seen.

Not exactly.  It was not consistent:

$ perl -E'package Foo::Bar; say Foo->can("can")'

> This change broke Params::Validate::Dependencies and no doubt breaks
> other stuff too.

I’m not so surprised it broke things, but it was never self-consistent

> Also it appears to be undocumented, including in
> perldelta.

It’s this entry:

=item *

C<< $class->can >>, C<< $class->isa >>, and C<< $class->DOES >> now return
correct results, regardless of whether that package referred to by C<$class>
exists [perl #47113].

It should probably have gone under Incompatible Changes.

See for the discussion.

I don’t think there is much we can do about it at this stage.


Father Chrysostomos

via perlbug:  queue: perl5 status: new

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