Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

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

Note that Perl does ship with a (still) core module called Class::Struct, which offers a simple syntax for OO programming.

An example I wrote 2 years ago is somewhat similar to the Point class example you provided. I only wrote it as a rebuttal to a claim that Perl OO programming is very hard without installing something from CPAN

package Planet; use Class::Struct mass => $, radius => $; use Math::Trig; sub density { my $self = shift; my $vol = 4/3*pi*($self->radius)**3); return $vol/($self->mass); } package main; use Planet; my $Jupiter = Planet->new(mass => 1.8E27, radius => 6.9E7); print "Jupiter has mass of " . $Jupiter->mass . " and "; print "radius of " . $Jupiter->radius . "\n"; print "It's density is " . $Jupiter->density . "\n";

Not as clean as your proposed syntax, but is something that can be used without needing anything from CPAN. And there are limitations, such as Class::Struct classes can only inherit from UNIVERSAL.


In reply to Re: Recap: The Future of Perl 5 by RonW
in thread Recap: The Future of Perl 5 by Ovid

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 imbibing at the Monastery: (6)
    As of 2019-05-22 12:50 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Do you enjoy 3D movies?



      Results (140 votes). Check out past polls.

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