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() );
|
|---|
| 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 | |
by chromatic (Archbishop) on Nov 25, 2013 at 20:05 UTC | |
by BrowserUk (Patriarch) on Nov 25, 2013 at 20:26 UTC | |
by chromatic (Archbishop) on Nov 25, 2013 at 21:42 UTC | |
by BrowserUk (Patriarch) on Nov 25, 2013 at 22:48 UTC | |
by ikegami (Patriarch) on Dec 01, 2013 at 17:38 UTC |