Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by BrowserUk (Pope)
on Nov 23, 2013 at 18:00 UTC ( #1064059=note: print w/ replies, xml ) Need Help??


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

In particular, if autoboxing were made a core feature ...

I see no purpose or benefit in autoboxing either. Pseud-OO doesn't float my boat in any way whatsoever.

See Re: What are the drawbacks of autobox? and Re^3: What are the drawbacks of autobox? and Re^5: What are the drawbacks of autobox? if you are interested in details, but in a nutshell, I see not just zero value, but negative value in wrapping over simple, obvious & well understood data abstractions like arrays and hashes in syntactic sugar to make them look like objects.

Some concepts and paradigms neatly lend themselves to object->action(args) notation, but for others it's a clunky, unhelpful force-fit that serves only to dumb-down the language, as if programmers are only capable of handling a single syntactic form.

Authors could reduce every sentence to the iconic 'The cat sat on the mat' form, rather than use forms like 'Upon 400 knot Persian silk rug, the feline reposed contently'; but damn literature would be boring.


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.


Comment on Re^5: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20
Re^6: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20
by tobyink (Abbot) on Nov 24, 2013 at 14:34 UTC

    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
      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.

Re^6: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20
by Grimy (Pilgrim) on Nov 25, 2013 at 17:14 UTC

    Authors could reduce every sentence to the iconic 'The cat sat on the mat' form, rather than use forms like 'Upon 400 knot Persian silk rug, the feline reposed contently'; but damn literature would be boring.

    Iíd have boring code over unreadable code any time. Code isnít supposed to have literary merit; itís supposed to be consistent.
      Code isnít supposed to have literary merit;

      Don't be so literal. Think. Interpret. Apply a little imagination.

      If someone says it is raining cats and dogs, do you look up expecting to see falling tabbies and chihuahuas?


      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1064059]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (15)
As of 2014-09-16 13:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (24 votes), past polls