Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Comment on

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

Yes, for the rare cases, it increases the number of calls. For the common cases, it can reduce the number of calls and complexity.

But this brings me back to my original suggestion, which was to leave :lvalue alone and provide :sassign (s=scalar) and :aassign (a=array since both 'list' and 'left' start with 'l') alternatives that make the easy stuff easy (and faster) but may not support the rare stuff (and, obviously, wouldn't support flipping between scalar and list contexts at run time).

Though you could still support general lvalue emulation for :sassign. For example, when an :sassign is used in an lvalue context other than a simple assignment (and perhaps a few other optimized cases), create a single closure that basicly curries the 'get' part of the method call and give this closure magic which means that assignments to it call it with the value to be assigned as the only parameter.1

So authors can choose to write 'set' routines in one piece instead of two while allowing their users to use assignment statements while Perl can automatically create a light-weight 'tied' closure only if the user uses the lvalue in a more complicated fashion.

But those who prefer to write 'set' methods in two pieces can optimize for the complex cases using :lvalue.

- tye        

1 I don't know if such makes sense for :aassign cases in Perl6 (it wouldn't in Perl5 because lists get flattened and supporting flattening of :aassign looks like a mine field to me).

In reply to Re^8: Experimenting with Lvalue Subs (trade-offs) by tye
in thread Experimenting with Lvalue Subs by Limbic~Region

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?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (5)
    As of 2018-04-21 14:13 GMT
    Find Nodes?
      Voting Booth?