Node:Hidden operators and style, Next:, Previous:Global variables and style, Up:Style



Hidden operators and style

Hiding operators away inside other statements can certainly make programs look elegant and compact, but it can make programs harder to understand. Never forget that besides being a set of instructions to the computer, programming is a form of communication to other programmers. Be kind to the reader of your program. It could be you in months or years to come.

Statements such as:

if ((my_int = (int)my_char++) <= --my_int2)
  {
    ...
  }

are not good style, and are no more efficient than the more longwinded:

my_int = (int) my_char;
my_char++;
my_int2--;

if (my_int <= my_int2)
  {
    ...
  }