in reply to Re^5: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20
in thread use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20

The advantage of autoboxing, is not to make this easier:

my $error = 3.1415927->minus( 22->divide( 7 ) )->abs();

But rather, if I write a function that deals with $href entirely though method calls rather than the built-in keywords, and document that I have done so, then somebody calling that function is now able to pass it, instead of a hashref, a blessed object providing the same interface; i.e. polymorphism.

This can be achieved somewhat using tied variables, but the interface is very low-level - it's not easy to, say, quickly override the order a foreach loop will traverse an array.

Besides which, in the former example you are hideously breaking encapsulation by using the assignment operator! ;-)

(my $error)->set_value( 3.1415927->minus( 22->divide( 7 ) )->abs() );
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

Replies are listed 'Best First'.
Re^7: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20
by BrowserUk (Patriarch) on Nov 24, 2013 at 19:25 UTC
    then somebody calling that function is now able to pass it, instead of a hashref, a blessed object providing the same interface; i.e. polymorphism.

    This is an interesting argument. Particularly this bit:

    it's not easy to, say, quickly override the order a foreach loop will traverse an array.

    Any chance of you knocking up an example for this?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Maybe not changing the traversal order, but it'd be nice to have some sort of iteration interface so that we could use for against a collection or generator or iterator or array without having to flatten the values into a list.

        it'd be nice to have some sort of iteration interface so that we could use for against a collection or generator or iterator or array without having to flatten the values into a list.

        Um, neither for my $item ( @array ) { ... } nor ... for @array; flatten?

        And for hashes, use ... while (key, value) = each %hash;


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.