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

strict whitespace

Expand Messages
  • Kai
    Hello! A few -more or less- philosophical questions regarding strict whitespace option: A)  Comment: JSLint doesn t like comments within function arg
    Message 1 of 2 , May 24, 2008
    • 0 Attachment
      Hello!

      A few -more or less- philosophical questions regarding strict whitespace option:

      A)  Comment:

      JSLint doesn't like comments within function arg parenthesis:
      function foo(bar/*,baz*/) {}

      or

      function foo(/*@cc_on  !@*/false) {}  // => Unexpected space after 'bar'.

      Why does JSLint treat this comment as space?


      B)  Space before parenthesis

      JSLint expects this:

      el.onclick = function () { //there has to be a space before parenthesis here... (1)
      function foo() {} // ...but not here (2)

      but doesn't like that:

      function
      foo () {  //=> Unexpected space after 'foo2'. (3)
      el.onclick = function() { // => Missing space after 'function'. (4)

      why is that?  just "because that's how it is" or is there a reason? shouldn't it be either with or without space?

      In
      (1), the "floating" empty parenthesis look very unusual to me. but maybe that's just because i'm used to 'bind" them to the function keyword (4)


    • Douglas Crockford
      ... Fixed. Thanks. ... To be clear, an anonymous function is a function without a name, not a function named function.
      Message 2 of 2 , May 24, 2008
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "Kai" <blafasel@...> wrote:
        >
        > Hello!
        >
        > A few -more or less- philosophical questions regarding strict whitespace
        > option:
        >
        > A) �Comment:
        >
        > JSLint doesn't like comments within function arg parenthesis:
        > function�foo(bar/*,baz*/) {}

        Fixed. Thanks.

        > B)� Space before parenthesis
        >
        > JSLint expects this:
        >
        > el.onclick = function () { //there has to be a space before parenthesis
        > here... (1)
        > function foo() {} // ...but not here (2)
        >
        > but doesn't like that:
        >
        > function foo () { �//=> Unexpected space after 'foo2'. (3)
        > el.onclick = function() { // => Missing space after 'function'. (4)
        >
        > why is that? �just "because that's how it is" or is there a reason?
        > shouldn't it�be either with�or without space?

        To be clear, an anonymous function is a function without a name, not a
        function named function.
      Your message has been successfully submitted and would be delivered to recipients shortly.