I'm hoping that the powers that be will allow this syntax once references to @str will always start with @ in perl 6. Then $str3 and @str3 will be clearly distinct things and then $str3..7 could be the equivalent of substr($str, 3, 5) which I think would be much more usable as I often know the start and end positions and have to perform (unintuative) math to translate this into a start/length pair. I quite like the idea of $str3,5,6,7 = $str5,3,7,6; as a similar concept to an array slice operation on a string, but I can see problems with it.
Probably not. I don't think slices will get quite that much support, and it's distinctly possible that it'll be considered acceptable for slices to be done programmatically via iteration, rather than in a single delegated call to the variables. (Yeah, I know that it'd be cool to get your tie code handed the entire slice, but it's a lot of work and makes some other things more difficult)

There'll be other tricks you can do that, while they don't solve this problem, can make other things nifty. Specifically for $foo[1][2][3][4]{z}, $foo will, if its tied, get handed the entire subscript list, and can do whatever it wants with them. In the common case it'll take the leftmost one and pass the rest on, but it doesn't have to--if $foo was a 4D array it could snag the first four and pass the rest, in this case the hash subscript, on to whatever it fetches.


In reply to Re: Re: Re: Re: Re: LVALUE refs by Elian
in thread LVALUE refs by BrowserUk

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.