Loading ...
Sorry, an error occurred while loading the content.

Re: [jslint] Loop

Expand Messages
  • John Hawkinson
    Douglas Crockford wrote on Tue, 14 Jun 2011 ... for(;;) is quite potentially confusing to novice programmers. while(true) is much
    Message 1 of 7 , Jun 14, 2011
    • 0 Attachment
      Douglas Crockford <douglas@...> wrote on Tue, 14 Jun 2011
      at 17:53:41 -0000 in <it8775+kvdj@...>:

      > But it doesn't, so instead of writing loop I must write either while
      > (true) or for (;;). I don't like either, so I am not sure which one
      > to prefer.

      for(;;) is quite potentially confusing to novice programmers.
      while(true) is much clearer.

      I hope we're not discussing what JSLint should complain about though,
      since both are legitimate stylistic choices that are unambiguous and not
      language hazards.

      Erik Eckhardt <erik@...> wrote on Tue, 14 Jun 2011
      at 11:25:39 -0700 in <BANLkTik0xdFw16bCvxAOF7HLTuHmjjfXLQ@...>:
      ...
      > So perhaps a second, optional parameter to while, whose use would make the
      > first parameter a loop initializer that runs before each loop before the
      > condition is tested:

      Err, it's not as if we are changing the language.

      --jhawk
    Your message has been successfully submitted and would be delivered to recipients shortly.