in reply to Re: A set of new operators. In keeping with the design of Perl?
in thread A set of new operators. In keeping with the design of Perl?

Well, a grep of my codebase (the obvious choice:) show that the ternary shows up at least once in approx. 60% of all my programs. Convinces me:)


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
  • Comment on Re: Re: A set of new operators. In keeping with the design of Perl?

Replies are listed 'Best First'.
Re: Re: Re: A set of new operators. In keeping with the design of Perl?
by zby (Vicar) on May 19, 2003 at 09:58 UTC
    But you should count it comparatively - for instance what is the percent of programs using the  + operator. And the shortcut  +=?

    Perhaps something like number_of_operator_uses / LOC_of_the_probe would be a better number than the procentum of programs.

      That probably would make for a better metric. Also, only counting those uses of the ternary where there are only 2 not 3 operands in play would also improve it; But I can't work out how to write the regex for that:)

      I take your point though, these operators probably wouldn't be use that often.

      Then again, how often have you ever used the ... version of the flip-flop operator? Other than when I was trying to understand it and find uses for it, I've never used it in anger, but I wouldn't exclude it from the language unless it caused the compiler or the interpreter some level of penalty on code that didn't use it. YMMV, and maybe there isn't enough reason to add something which is obviously more work than just leaving something that is already there.

      Oh well. T'was just a thought:) Though it is a recurring one going back many years to other languages that have the ternary op. Perl has resolved so many of the annoyances of syntax that bugged me in C and Java, that this seemed like another candidate.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
        You've got me thinking. I like the .. operator in scalar context (and if you use it you need the ... too for the special case), but I can't say why I like it more than the ternary operator. I would agree that both are of marginal use .

        A feeling is something you can't argue about - but I believe there must be an analyzis backing it.

        Update: added "scalar context" in first sentence.