On Sun, Sep 10, 2000 at 09:22:39PM -0700, Nathan Wiger wrote:
> Regardless of my huge error above, this doesn't change the fact that
> this is exactly what tie() does currently in Perl 5. That is:
> 
>    tie @a, 'Matrix';
>    push @a, $stuff;
> 
> Now changes the meaning of push() in the current package. So the only
> real difference in this situation from a user standpoint is that "PUSH"
> becomes "push" per the RFC, plus they can now do this with any function
> they please.

Things like push(), exists(), etc... all have well defined meanings.
If you add a push() method to your tied class its going to be for
putting stuff onto the end of a list.  Methods which override built-in
functions are obvious enough.

However, anything which is *not* a built-in, may only share its name
and nothing else.

    use Some::Module qw(do_something);

    tie @a, 'Matrix;
    do_something @a;

Harmless enough.  But what happens if do_something() looks like this:

    sub do_something {
        my @a = @_;
        add @a, qw(some stuff);
    }

If Matrix has an add() method, then it will interfere with
Some::Module::add() and cause do_something() to do something really,
really different than what was expected.  The problem is that
Matrix::add() and Some::Module::add() are related by name *only* and
are not interchangable.

The danger is of methods unintentionally being called in place of
unrelated functions.

-- 

Michael G Schwern      http://www.pobox.com/~schwern/      [EMAIL PROTECTED]
Just Another Stupid Consultant                      Perl6 Kwalitee Ashuranse
MORONS!

Reply via email to