sundarurfriend has asked for the wisdom of the Perl Monks concerning the following question:

I've checked the relevant perldelta and perldoc pages, but couldn't find the answer to a question I've had for a while:
What does the '...' yada-yada give us that 'die "Unimplemented"' doesn't already do? What was the reasoning behind overloading an already (arguably) complicated range/flip-flop operator?
  • Comment on The reason for the "yada yada" operator

Replies are listed 'Best First'.
Re: The reason for the "yada yada" operator
by chromatic (Archbishop) on Jul 11, 2013 at 16:22 UTC

    It's shorter and reads better, which is an argument for a lot of things in Perl, including say.

    It's not overloading the range or flip/flop operator in the grammar sense, because there was no syntactic construct in the Perl 5 grammar for ... as a term or nullary operator.

      Also, there were already gazillions of examples in documentation like:

      if (frobnicate(42)) { ... }

      Implementation of the yada-yada operator made them all syntactically correct. :-)

      package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
      > It's shorter and reads better

      The "reads better" part is hugely subjective though, and in my opinion ... only obfuscates thing a bit. die 'Unimplemented' is self-documenting, can be read out aloud, and it's immediately obvious what it does, whereas ... just looks pretty and cool (IMHO of course).

      > It's not overloading the range or flip/flop operator in the grammar sense

      It still overloads the actual sequence of characters ..., which is a mental burden, and IMO unnecessary for such a miniscule benefit. Perl developers are used to the scalar/list context distinction between range and flip-flop operation, but this introduces new behavior in yet another context for pretty flimsy reasons.

        The "reads better" part is hugely subjective though...

        Maybe, but as tobyink reminded me, it was already an implicit operator in plenty of documentation, which all of a sudden started to compile correctly.

Re: The reason for the "yada yada" operator
by davido (Cardinal) on Jul 11, 2013 at 17:09 UTC

    Consistency and skim-ability, I think.

    die "Unimplemented."; die "Not implemented."; croak "Unfinished."; confess "Still needs work.";

    ...then...

    perl -nE 'say "$.: $_" if /Unimplemented/i' source.pl

    ...vs...

    perl -nE 'say "$.: $_" if /\.{3}/' source.pl

    Both will turn up the occasional false positive. But consistent use of '...' will avoid misses when skimming code for gremlins that haven't been caught yet.

    It's probably the 2nd least useful operator introduced in modern Perl (~~ is #1), but unlike #1 it does no harm, and at least could contribute to a little less time spent looking for unfinished code.


    Dave

Re: The reason for the "yada yada" operator
by BrowserUk (Patriarch) on Jul 11, 2013 at 16:28 UTC

    Good question. Another post-5.10 useless change.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.