in reply to Re^3: What's so bad about &function(...)?
in thread What's so bad about &function(...)?

@{[@foo]} is really wrong, for the obvious reason that it copies the contents of @foo into a new (anonymous) array, so that, for example, splice( @{[@foo]}, 0, 5 ) does not modify @foo.

But why is @{\@foo} wrong? Whatever the answer is, the same could be said of &foo() (aside from the extremely tiny overhead of taking and dereffing a ref).

We're building the house of the future together.

Replies are listed 'Best First'.
Re^5: What's so bad about &function(...)?
by Anonymous Monk on Dec 08, 2005 at 16:48 UTC
    But why is @{\@foo} wrong? Whatever the answer is, the same could be said of &foo() (aside from the extremely tiny overhead of taking and dereffing a ref). It's only wrong in the sense that:

     $great_answer=(((1+1)**(1+1+1))-1)*(1+1+1)*(1+1);

    is "wrong"; it's too complicated, and "should" read:
     $great_answer=42;

    (Alternatively, it's overly complicated for some good reason which was left undocumented, which is IMHO more wrong. :-) )