in reply to Re: Getting rid of "new" (wrong target; perl6)
in thread Getting rid of "new"

and I'm even optimistic that such could be done for Perl 5. But, for now, a good approach is something like:

use Data::Heap::Whatever 1.1 ( \my $Heap

That reference constructor there is a nit for me. Why should the user be required to provide it? There is no functional reason that it is needed. The import routine should get an alias to the whatever was passed in so I cant really see a reason for it.

Sorry, but I've encountered this design choice a lot (DBI does it somewhere iirc) and it always kind of irritates me as it seems to me to be so unperlish.

---
$world=~s/war/peace/g

Replies are listed 'Best First'.
Re^3: Getting rid of "new" (superfluous reference constructor)--
by tye (Sage) on Jul 07, 2006 at 15:59 UTC

    An alternative:

    use Data::Heap::Whatever 1.1 ( Factory => my $Heap, ...

    But the passing of a reference has two purposes:

    1. It lets us reliably distinguish between an option name and a variable being passed in to receive a factory, thus allowing the more stream-lined usage
    2. It makes the fact that $Heap will be modified explicit, serving as a form of documentation

    I don't have a strong preference (other than wishing use could return a factory), though.

    - tye