Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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 ( [id://11127989]=note: print w/replies, xml ) Need Help??


in reply to Re^3: 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

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

  • Comment on Re^4: Situation where warning "Found = in conditional, should be" seems obsolete (documentation - C terminology)
  • Select or Download Code

Replies are listed 'Best First'.
Re^5: Situation where warning "Found = in conditional, should be" seems obsolete (documentation - C terminology)
by rsFalse (Chaplain) on Feb 06, 2021 at 20:07 UTC
    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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11127989]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (1)
As of 2024-04-24 14:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found