in reply to Re^3: Is there a wantobject like wantarray?
in thread Is there a wantobject like wantarray?

I use it so it must be popular!

URI , Path::Class (update: should mention Path::Tiny too as it’s starting to replace the Path::Class stuff for me), a bunch of Mojo stuff come to mind… a good handful of others in my tree. :P

ack use\ overload /usr/local/lib/perl5/site_perl/5.18.2/ | ack '""' | +wc -l 74

Replies are listed 'Best First'.
Re^5: Is there a wantobject like wantarray?
by LanX (Saint) on Sep 25, 2014 at 16:40 UTC
    > I use it so it must be popular!

    Well ... you certainly think you are funny ... ¹

    Do you know if this approach involves changing the nature² of the scalar after its first use, to speed up things afterwards?

    (Maybe I'm confusing this now with quantum superposition magic ...)

    Cheers Rolf

    (addicted to the Perl Programming Language and ☆☆☆☆ :)

    ¹) you are! ;-)

    ²) i.e. unblessing

      I don’t know but I’d be very surprised if it did. This is not my forté, more my piano (see! I am funny), but this seems to support the notion; both dumps being the same–

      use 5.012; use Devel::Peek; package Bingo { use Moo; use overload '""' => sub { +shift->ohai }; has ohai => is => "rw"; }; my $bingo = Bingo->new( ohai => "DER" ); Dump $bingo; say "\n$bingo\n"; Dump $bingo;
        Sorry my question was not well phrased.

        Maybe better "involves possibility" or "allows".

        The point about a "want context" is to return the right data type.

        Returning an object could be a work around, if it transforms into the right data type after first access.

        Otherwise there would be a performance penalty for simple scalars.

        But not sure if unblessing or untying within an accessor is a reliable approach with calculated risk.

        Cheers Rolf

        (addicted to the Perl Programming Language and ☆☆☆☆ :)