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

Re: (functions)

Expand Messages
  • santini.alberto
    ... disallow option and funcblock option. Regards, Alberto
    Message 1 of 7 , Mar 23, 2009
    View Source
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:

      > There is a lot of code that is unaware of this style, so I need an option to control it. Should it be a tolerate option or a disallow option, and what should the option be called?
      >

      disallow option and "funcblock" option.

      Regards,
      Alberto
    • Merlin
      ... Should it be a tolerate option or a disallow option, and what should the option be called? ... Suggest Disallow bad (immediate) invocation . Preference
      Message 2 of 7 , Mar 24, 2009
      View Source
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
        >
        > I have seen a lot of confusion around use of immediate invocation of functions. I think JSLint can help if we can insist on some specific styling.

        Should it be a tolerate option or a disallow option, and what should the option be called?
        >

        Suggest "Disallow bad (immediate) invocation". Preference "badcall" ?
      • dom@happygiraffe.net
        ... badfunk ? :) -Dom
        Message 3 of 7 , Mar 24, 2009
        View Source
        • 0 Attachment
          On Tue, Mar 24, 2009 at 05:28:23AM -0000, santini.alberto wrote:
          > --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
          >
          > > There is a lot of code that is unaware of this style, so I need an option to control it. Should it be a tolerate option or a disallow option, and what should the option be called?
          > >
          >
          > disallow option and "funcblock" option.

          "badfunk"? :)

          -Dom
        • m m
          disallow: Wrapped immd function literals? -----Original Message----- Date: Monday, March 23, 2009 7:45:26 pm To: jslint_com@yahoogroups.com From: Douglas
          Message 4 of 7 , Mar 24, 2009
          View Source
          • 0 Attachment
            disallow: Wrapped immd function literals? -----Original Message-----
            Date: Monday, March 23, 2009 7:45:26 pm
            To: jslint_com@yahoogroups.com
            From: "Douglas Crockford" <douglas@...>
            Subject: [jslint] (functions)

            I have seen a lot of confusion around use of immediate invocation of functions. I think JSLint can help if we can insist on some specific styling.

            I am proposing that when a function literal is to be called immediately, then the whole expression be wrapped in parens. So

            var foo = function () {}(); // bad
            var foo = (function () {})(); // bad
            var foo = (function () {}()); // good

            Also, a function cannot be placed alone in parens.

            var foo = (function () {}); // bad
            var foo = function () {}; // good

            There is a lot of code that is unaware of this style, so I need an option to control it. Should it be a tolerate option or a disallow option, and what should the option be called?
          • Frederick Staats
            Most code that I work with is of the following form which I would not like to have called bad : var foo = (function () {})(); In reality this code really
            Message 5 of 7 , Mar 24, 2009
            View Source
            • 0 Attachment
              Most code that I work with is of the following form which I would not like to have called "bad":
              var foo = (function () {})();

              In reality this code really looks like:

              var foo = (funciton () {
              // Somethign interesting here;
              })();

              Which looks similar to how passed functions look:
              myfunc(function () {



              I can not recall ever seeing the following form. I think is harder to read and do not believe it is in as common use.
              var foo = (function () {}());

              I don't really think we are solving a big problem by giving styling guidelines here.

              --
              Frederick (Fritz) Staats

              --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
              >
              > I have seen a lot of confusion around use of immediate invocation of functions. I think JSLint can help if we can insist on some specific styling.
              >
              > I am proposing that when a function literal is to be called immediately, then the whole expression be wrapped in parens. So
              >
              > var foo = function () {}(); // bad
              > var foo = (function () {})(); // bad
              > var foo = (function () {}()); // good
              >
              > Also, a function cannot be placed alone in parens.
              >
              > var foo = (function () {}); // bad
              > var foo = function () {}; // good
              >
              > There is a lot of code that is unaware of this style, so I need an option to control it. Should it be a tolerate option or a disallow option, and what should the option be called?
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.