Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^4: What are the drawbacks of autobox?

by LanX (Saint)
on Mar 01, 2010 at 11:31 UTC ( [id://825873]=note: print w/replies, xml ) Need Help??


in reply to Re^3: What are the drawbacks of autobox?
in thread What are the drawbacks of autobox?

Show me a valid, real-world use case in which there is a significant advantage to treating the number 3 as an object rather than as a simple integer

Your reducing the possibilities of autobox to a little feature.

And did I ever say I want to call a method on 3?

I'm really surprised by the emotions caused by this little question about the technical side-effects of a cpan module, I didn't expect the Spanish inquisition...

Cheers Rolf

  • Comment on Re^4: What are the drawbacks of autobox?

Replies are listed 'Best First'.
Re^5: What are the drawbacks of autobox?
by dsheroh (Monsignor) on Mar 01, 2010 at 12:49 UTC
    Fair enough. On further reflection, this thread is suffering from a bad case of excluded-middle: The anti-autobox folks (myself among them) are trying to push you into defending the position that everything should be objects, when you've not stated that this should be the case.

    I do see potential benefit to making at least some array/list/hash operations available as methods. I don't see it as a strong benefit in general, but reasonable people can differ on that. In the particular case of your javascript fruit basket, it reads more naturally to me in the standard Perl syntax than the js/autobox version, but that may just be a matter of acclimation; what would read most naturally to me would be "push 'kiwi', @fruits", to mirror English "push kiwi onto fruits", but I've not seen a language which allows that ordering.

      Try Common Lisp, it has (pushobj place)
      Hi

      > The anti-autobox folks (myself among them) are trying to push you into defending the position that everything should be objects, when you've not stated that this should be the case.

      Thx finally my message got thru. :)

      To be clear: After use autobox you are still free to write push @fruits, 'kiwi', that's perfect TIMTOWTDI! (UPDATE: And it's not turning the primitives into objects!)

      > what would read most naturally to me would be "push 'kiwi', @fruits", to mirror English "push kiwi onto fruits"

      Thx again, you brought an example I had in mind about how absurd this argument about Perl reflecting natural language is.

      For technical reasons the direct object is NOT in first position in Perl's push()¹

      BUT with method chaining  $fruits_ref->push('kiwi')->push('banana') reflects naturally:

      "Take fruitbasket! Push kiwi! Push banana! ..."

      In natural grammar: The indirect object becomes a matter of context!

      (Nota bene: I'm not saying this example is better than  push @fruits,'kiwi','banana', it's just a fucking example about the analogies of natural and computer languages)

      > I don't see it as a strong benefit in general,

    • One of my vision is to code in Perl and to run it on JS Engines. Contrary to other languages Perl has the flexibility to allow this. And JS is very flexible in extending the core functionality.

      (My example should show a way to achieve this.)

      And JS Engines are universally available in Browsers , in Flash (Action Script) in .NET and Java (Rhino) and the JIT compiler of Chrome and and ...

      OTOH Perl has nothing to cope with IronPython or JRuby, which ARE important in marketing these languages. Code-reuse is alway an issue!

      "Then there's JavaScript, a nice clean design. It has some issues, but in the long run JavaScript might actually turn out to be a decent platform for running Perl 6 on." -- Larry Wall

    • Another vision is to show to the hype folks running to Ruby that all there OO concepts from Smalltalk can be easily backported one-by-one to Perl.

      Cheers Rolf

      ¹) you can't turn the prototype push(\@;@) around, without limiting the list of pushed elements!

      UPDATE: added links.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-19 17:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found