Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Semantically, you are right.

But, that is not the issue Ovid raised in Recap: The Future of Perl 5.

In his proposal, Ovid seeks to reduce the number of required steps and simplify the syntax in Perl 5's OO system.

As to why I said Python's OO system seems to have changed since Larry stole from it, see the Python 3 example:

class Dog: # Class Attribute species = 'mammal' # Initializer / Instance Attributes def __init__(self, name, age): self.name = name self.age = age # Instantiate the Dog object philo = Dog("Philo", 5)

__init__ is called with an already "blessed" ref to an already allocated container. __init__ only sets values to the objects's fields.

The 1-to-1 translation to Perl would be (using signatures to reduce "noise"):

package Dog; our $species = 'mammal'; sub __init__ ($class, $name, $age) { my $self = {}; $self->{name} = $name; $self->{age} = $age; bless $self, $class; } package main; my $philo = Dog->__init__('Philo', 5);

Even if we make __init__ more Perl-ish (still using signatures):

sub __init__ ($class, $name, $age) { my $self = bless {name => $name, age => $age}, $class; }

Ovid would still point out that Perl is requiring the programmer to perform 2 extra steps: Allocate the container and create a blessed reference to the container.

I don't know which version of Python Larry stole the OO system from, so I don't know what Larry changed. But, at least to me, Perl 5's classes look more like Smalltalk classes than Python 3 classes.


In reply to Re^4: OO systems and Perl 5 (Was: Recap: Future of Perl 5) by RonW
in thread OO systems and Perl 5 (Was: Recap: Future of Perl 5) by RonW

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (3)
    As of 2019-05-22 01:07 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Do you enjoy 3D movies?



      Results (138 votes). Check out past polls.

      Notices?
      • (Sep 10, 2018 at 22:53 UTC) Welcome new users!