[Raleigh-talk] Messing around with symbol tables
Michael Peters
mpeters at plusthree.com
Wed Dec 2 09:13:28 PST 2009
On 12/02/2009 12:05 PM, Paul Bennett wrote:
>>> confess('Object cannot cmp()') unless UNIVERSAL::can($orig, 'cmp');
>>> confess('Object cannot clone()') unless UNIVERSAL::can($orig, 'clone');
>>
>> You should be calling can() as $orig->can() instead of UNIVERSAL::can().
>
> I disagree. What if "$orig"::can() is overriden with something utterly
> unlike capability testing? It would be outside what I consider safe,
> sane, and consensual, but not implausible.
The alternative is that if a module purposefully overrides can() so that
it behaves well (like for instance it has an AUTOLOAD method that can
dispatch cmp and clone) then your usage would fail. So the module author
tried to do the right thing but now it won't work because you ignored it.
--
Michael Peters
Plus Three, LP
More information about the Raleigh-talk
mailing list