in reply to Re: Re: Fringe case slice behavior
in thread Fringe case slice behavior

Was any conclusion reached as a) whether there would be such a keyword?
Not by me. :-)
b) What it is likely to be?
I suspect a pop should be made to do the expected thing, in which case you have your keyword (or at least, method name). But as I said, a [-1] subscript will certainly work. It may well become the idiom of choice for when you really do want to select the last value.

But note that many uses of the C-style comma operator are in fact in void context, in which case you don't much care whether it returns the last value or a reference to the list, since it's just going to throw it away anyway. So you can just use comma in those cases.

Replies are listed 'Best First'.
Re: Re: Re: Re: Fringe case slice behavior
by BrowserUk (Patriarch) on Jan 14, 2004 at 02:37 UTC
    Not by me. :-)

    Hence my question :)

    The particular case being [news://nntp.perl.org/perl.perl6.language/16066|discussed] (for example) was the replacement of

    ... warn "some error message", return unless condition;
    by
    ... warn "some error message" also return unless condition;

    Also discussed was

    for( my $i=1 also my j=3; cond; $i++ also $j+=3 ){ ...

    I'm more than happy to see the demise of the comma-operator-separated-list in a scalar context -v- flattened-array in a scalar context anomoly, and it's replacement by (1,2,3)[-1] for those rare occasions where that is required.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    Timing (and a little luck) are everything!