I don't think it's true that people simply want assignable subs. People want subs that can be used like variables, including not only placement on the left-hand side of an assignment but also in places such as pre- and postinc- and decrement.

substr( $self->seq, 20, 15 ) =~ tr/178/22x/;

It is not possible to handle the general case without requiring two different invocations, one to fetch the value, one to assign to it after determining the new value. Only the trivial case where the rvalue does not depend on the previous value of the lvalue can be handled with a single invocation.

So there are two conceptually distinct tasks involved.

I believe that handling both with a single sub is as undesirable as heavy overloading of @_'s semantics. So two separate pieces of code will be required in any case.

Once you arrive at that point, whether you correlate the subs to each other via multimethod dispatch, some closure scheme, the tieing interface, or something else completely, really makes no difference at all, assuming all of these cases will be similarly concise to express and efficient to execute.

Makeshifts last the longest.


In reply to Re^5: Experimenting with Lvalue Subs by Aristotle
in thread Experimenting with Lvalue Subs by Limbic~Region

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.