Venus is a rich demonstration that it is possible to implement "Everything is an object" in Perl. But honestly, I doubt that it is much more than that.

Objectification of arrays and hashes makes it look like Java, which isn't bad, but no particular benefit either. It gets weird when primitives like numbers and strings are objectified. Venus::Number objects can, thanks to overload, be manipulated with the usual arithmetic operators. However, as soon as I apply an arithmetic operator on a Venus number, the result loses its object properties and is just a plain number. There are no methods like $one->add($two) which would allow to return new Venus::Number objects.

Here's some experiments I ran. Some results weren't as I expected.

use 5.028; use Venus qw(catch); use Venus::Number; my $one = Venus::Number->new(1); my $two = Venus::Number->new(2); say "one = ", $one; # one = 1 say "one = $one"; # Argument "one = " isn't numeric in addition (+) .... # 10 <---- Venus::Number objects don't interpolate print "two = "; $two->print_string; print "\n"; # two = 2 <--- Methods don't interpolate either # Arithmetics my $three = $one + $two; say "three = ", $three; # three = 3 <---- Now it does interpolate print "three = "; $three->print_string; print "\n"; # Can't locate object method "print" via package "3" # <---- but has lost its blessing # Strings use Venus::String; my $just = Venus::String->new('Just'); my $another = Venus::String->new('another'); my $perl = Venus::String->new('Perl'); my $hacker = Venus::String->new('hacker'); say "$just $another $perl $hacker"; # ----> hackerPerlanotherJust

In reply to Re: What if Perl had an OO standard library? by haj
in thread What if Perl had an OO standard library? by awncorp

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.