Of course! Changing the autobox is comparable to messing with CORE:: or UNIVERSAL:: in Perl or changing the prototype of Array() in JS.

That wasn't my point... I was talking about design decissions an cleaner syntax.

If it's unclear if you will be going to bless or tie a _specific_ primitive array into a class and you wanna stay flexible you will have to use references right from the beginning:

And this will force you into to sigil accrobatics like writing things like  push @$ref,"elem"

In this case - i.e. only when dealing with primitives - it's an option to use  $ref->push("elem") right from the beginning to have a cleaner syntax. (The resulting caveates like speed punishment are listed in the OP.)

But IF you decide later to extend this class you can _bless_ $ref into a new class with list_active -method, without changing the interface you used and without poluting other arrays.

Anyway my prefered - "utopic" - syntactic solution is to have an extra special sigil for arr_refs, such that you can still write push €ref,"elem" (or even €ref->push("elem") according to your taste) without sigil accrobatics.

This (and other syntactic simplications) would make Perl5 much easier to use and to learn without breaking compability to older sigils. (And would build a migration bridge to Perl6) Perl forces you anyway to use refs in bigger programs, IMHO there is no big point of @ and % if you can't use them to distinguish the underlying structures.

BTW: > @employees->list_active

shouldn't be possible ... neither with autobox nor blessing, you will have to write something like

\@employees->list_active

Cheers Rolf


In reply to Re^6: Benefits of everything is an object? Or new sigils? by LanX
in thread Benefits of everything is an object? Or new sigils? by LanX

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.