Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Which and why?

Name: Anonymous 2010-12-26 13:05


if ((......)&&(......))

or

if()
   if()
      ...

Name: Anonymous 2010-12-26 13:12

same shit
most compilers do it by evaluating the first condition and branch if it fails. If it doesn't fail they eval the second and so on.

Name: Anonymous 2010-12-26 13:12

>>2
Which means: do as you please, or as you read it better.

Name: Anonymous 2010-12-26 13:16

car

Name: Anonymous 2010-12-26 13:18

When body is one line long and a statement:

if ((...) &&
    (...) &&
    (...)) body;
[else if
   ((...) &&
    (...)) body;
[else ...;]]


When body is more than one line long:

if ((...) &&
    (...) &&
    (...)) {
    body;
    ...;
} [else if
   ((...) &&
    (...)) {
    body;
    ...;
} [else {
    ...;
}]]


In general, it's always
((...) &&
 (...))

Why? I'm used to Lisp, so I find it more readable than if ((...) && (...) && (...)) ...;
The awkward indentation of else if is needed to get conditions and body aligned with the first if, but I usually never need complex else ifs.

Name: Anonymous 2010-12-27 20:17

>>2
>most compilers do it by evaluating the first condition and branch if it fails

Most compilers!? It's called short circuiting and shit loads of programs depend on this so-called ``optional'' behaviour for their integrity. Surprise, surprise it's actually standard, get back to /g/ you codeless fiend.

Name: >>6 2010-12-27 20:18

damnit

Name: Anonymous 2011-02-04 13:23

Name: Anonymous 2013-09-01 10:20



            r- 、-, ‐- 、_
        ,. ,べ´  ∨   |/ ̄ヽ-、
        / 「ヽ >''"´ ̄ ̄`ヽ/_/´|、
      /   ノ-/   /       `ヽ ヘ
     ,'   .| 7   .,' /メ、/|   ,|    Y}
      |   |/    | ,ァー=、| / |  ,ハ.  ||
      |   / /   |./  /´! レ'  |/-|  八  紅魔館の警備ですか
     |  ' ̄/    八 弋リ    ァ!'T| イ「`
     |   ∠.,_,. イ},., `     , lリ ハ|∨'   大丈夫です、問題ありません
      ;  /   {Y}|         ゙|Y
     / イ    }X{ト、     ‐    ハ
     ,' /| ./   {Y}|   、     , ィ|  }     rt
     レ  ヽ|   /∨ハ、   `lァ7´|}Y{ /    r' ´ ̄`ヽ     (  )
       r'"´[ ̄\Kこ{ヽrムイ  {X}./     |´ ̄ ̄'|    ( )
      , '"´ ̄`ヽ / Tヽに>く{ヽ}Y{!       | 塩  | r======r┐
     /      ∨ } \/ハ\}ムに}    |     | 、__ノ‐'
   /       ヽ| /ト-く__」-┘∨、  ヽ二二二二二二二二ン
  .{ Red Magic  Y} /:::::::::::l::}:::::::ハ ヽ      {  '´  /
   ゝ   _,. --= 、  ,ハ/::::::::::::::り::::::::::} }    ,'    ./
   く ,-──-、 Y、:::::::::::::::::::::::::::::::イにlヽ.  /    ,'

Don't change these.
Name: Email:
Entire Thread Thread List