http://qs1969.pair.com?node_id=11127988


in reply to Re^2: Situation where warning "Found = in conditional, should be" seems obsolete (documentation - C terminology)
in thread Situation where warning "Found = in conditional, should be" seems obsolete

I agree with you.
You gave a good answer instead of me :)
>>what do you mean by "named being conditional"
I mean that when I press CTRL+F and ask for "condit..." in perlop it didn't land into 'and', 'or' sections.
By the way a warning warns about '=' been found inside "conditional", so an operator 'and' worked with "conditional". Sorry if I'm not pretty good at understanding english.

And how about replacing infamous variable names '$a' and '$b' with foo/bar or so.

UPD.: I changed my mind and now I disagree with '?:' naming 'Ternary operator' and suggest explicitly name it 'Ternary conditional operator'. Because I think that the name 'ternary' is too abstract and meaningless (it only says about how much operands it operates on). OK, it is the only ternary operator by now, but why not future Perl include other ternary operators?!

Replies are listed 'Best First'.
Re^4: Situation where warning "Found = in conditional, should be" seems obsolete (documentation - C terminology)
by LanX (Saint) on Feb 06, 2021 at 19:50 UTC
    Terminology is not easy if it involves history and parallels to other (normative) languages.

    see also https://en.wikipedia.org/wiki/Conditional_operator

    The Conditional operator is supported in many programming languages. This term usually refers to ?: as in C, C++, C#, Python, and JavaScript.

    However, in Java, this term can also refer to && and ||

    When Perl was born, C-programmers where one of the main target groups.

    But as you see "Java" is doing it like you suggested.

    And in Perl it's not only that

    • and has the same "flow control" like if
    but also
    • if returns a value like the operand and

    As I said, both are implemented with the same OP-Code.

    edit

    At the same time we want documentation to stay concise, otherwise it's considered "too complicated"

    I think adding an extra section "Control flow in conditional operators" with these deeper informations and linking to it from ?: and && or || might solve the issue.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      Do '&&' and '||' short-circuit in C?

      >>if returns a value like the operand and

      Ye, I was surprised, when if returned the result of its conditional (because it was false) and didn't proceeded to a sencence! (The long discussion about this finding was here: printing unitialized value of the 'do BLOCK')
        > Do && and || short-circuit in C?

        Yes, and Perl introduce and and or as low precedence alternatives.

        > The long discussion

        yes we had this before

        simple example

        DB<226> p do { unless (42) { } } 42 DB<227>

        Please keep in mind that "ternary operator" is not correct either, since it's a mathematical term classifying a whole family of operators with 3 operands. ? : is just the only ternary one in these languages.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery