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

I remember seeing some discussion about replacing the c-style comma operator with a keyword that achieved a similar effect. Various option where discussed -- also & then were muted I think.

Was any conclusion reached as a) whether there would be such a keyword? b) What it is likely to be?


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

Replies are listed 'Best First'.
Re: Re: Re: Fringe case slice behavior
by TimToady (Parson) on Jan 14, 2004 at 02:17 UTC
    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.

      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!

Re: Fringe case slice behavior
by Abigail-II (Bishop) on Jan 13, 2004 at 21:22 UTC
    I cannot remember any discussion to replace the C-style comma in the 7 years that I've read p5p. I don't think such a proposal would make any chance, for several reasons: there is already a synonym for the comma: =>; it doesn't save anything, instead of a single keystroke, you'd have to use at least 4, but often 5. And it has the potential to break existing code.

    The comma is a well-known construct - especially amongst the people on p5p, as they tend to know C quite well.

    Abigail

      I didn't actually mention p5p.

      The discussion was on the p6lang list, and I was responding to "That means there's no C-style comma operator in Perl 6".


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