I agree that the dot syntax is a bit easier to type, and I think overall the syntactic change is worth the (very small, for me anyway) pain it takes to re-learn. A more significant change, in my mind, is how most object code will actually be written. It won't take nearly as much code to accomplish the same goals. Consider an example:

class Point { has $.x; has $.y; method str { return $.x ~ "x" ~ $.y; } } my $point = Point.new(x => 2, y => 3); say $point.str;

Compared to the equivalent Perl 5:

{ package Point; sub new { my $name = shift; my %attr = @_; return bless { %attr }, $name; } sub x { my $self = shift; return $self->{x}; } sub y { my $self = shift; return $self->{y}; } sub str { my $self = shift; return $self->x . "x" . $self->y; } } my $point = Point->new(x => 2, y => 3); print $point->str, "\n";

I think you'll agree that the Perl 6 version makes it a lot easier to get on to the heart of the matter. I really like it.

(Of course, we can get most of the same conciseness in Perl 5 with Moose, which I am very excited about. But that came as a result of the Perl 6 OO design, so credit where credit is due.)


In reply to Re: OO in Perl 6 by revdiablo
in thread OO in Perl 6 by Scott7477

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, details, 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, summary, 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.