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

SV: [jslint] Re: Indentation quirk?

Expand Messages
  • caerusx
    Hi For one liners it s better to use lambda forms. No matter how descriptive name is, better to see an actual code immediately, if it just one line. Often
    Message 1 of 7 , Jan 23, 2012
    • 0 Attachment
      Hi

      For one liners it's better to use lambda forms. No matter how
      descriptive name is, better to see an actual code immediately, if it
      just one line.

      Often lambda forms are used just to bind some parameters to existing
      functions, or just to pass some expression (e.g. sort function), or
      some simple filtering function. And it's weird to give an explicit
      name to these one liners in language supporting lambda forms.

      It's just my opinion.

      Nevertheless, I don't think that it is a good idea to rewrite a
      readable code to less readable just to pass a lint.

      Like in my other topic with cyclic dependent functions. It is possible
      to work around lint requirement by splitting declarations of variable
      and assignment to separate statements, but why to do this if it
      actually complicates code.


      --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@...> wrote:
      >
      > Good morning,
      >
      > Your problem seems to be your insistence on declaring a function inside a function call. This is much better (from a readability perspective):
      >
      > function myfunc() { � }
      > func(1, 2, 3, 4, 5, 6, myfunc);
      >
      > Regards,
      > Jakob
      >
      >
      > Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] P� vegne af caerusx
      > Sendt: 23. januar 2012 09:57
      > Til: jslint_com@yahoogroups.com
      > Emne: [jslint] Re: Indentation quirk?
      >
      > Good morning!
      >
      > I was thinking about mixing open and compact forms. And I think
      > disallowing to use open inside compact and vice verse brings
      > inconveniences.
      >
      > It's fine for lint to use function parameters in compact form:
      >
      > func(1, 2, 3,
      > ~~~~~4, 5, 6, function () {});
      >
      > But when one parameter listed in compact form internally contains open
      > form, lint fails to validate:
      >
      > func(1, 2, 3,
      > ~~~~~4, 5, 6, function () {
      > ~~~~~});
      >
      > To pass validation, it's needed to rewrite outer block to open
      > form. Do you agree that code below, which is correct from lint point
      > of view, looks worse for a human?
      >
      > func(
      > ~~1,
      > ~~2,
      > ~~3,
      > ~~4,
      > ~~5,
      > ~~6,
      > ~~function () {
      > ~~}
      > );
      >
      > [Non-text portions of this message have been removed]
      >
    • Jakob Kruse
      Hi The formatting problem you outlined had to do with how your code should be distributed over multiple lines, so it is not “just one line”. If it was just
      Message 2 of 7 , Jan 23, 2012
      • 0 Attachment
        Hi

        The formatting problem you outlined had to do with how your code should be distributed over multiple lines, so it is not “just one line”. If it was just one line jslints line breaking rules would hardly apply.

        I recommend that you improve the readability of your code because that makes it better code. That it also then happens to comply with the recommendations of jslint is an added bonus.

        /Jakob

        Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] På vegne af caerusx
        Sendt: 23. januar 2012 12:38
        Til: jslint_com@yahoogroups.com
        Emne: SV: [jslint] Re: Indentation quirk?




        Hi

        For one liners it's better to use lambda forms. No matter how
        descriptive name is, better to see an actual code immediately, if it
        just one line.

        Often lambda forms are used just to bind some parameters to existing
        functions, or just to pass some expression (e.g. sort function), or
        some simple filtering function. And it's weird to give an explicit
        name to these one liners in language supporting lambda forms.

        It's just my opinion.

        Nevertheless, I don't think that it is a good idea to rewrite a
        readable code to less readable just to pass a lint.

        Like in my other topic with cyclic dependent functions. It is possible
        to work around lint requirement by splitting declarations of variable
        and assignment to separate statements, but why to do this if it
        actually complicates code.

        --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@...> wrote:
        >
        > Good morning,
        >
        > Your problem seems to be your insistence on declaring a function inside a function call. This is much better (from a readability perspective):
        >
        > function myfunc() { � }
        > func(1, 2, 3, 4, 5, 6, myfunc);
        >
        > Regards,
        > Jakob
        >
        >
        > Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] P� vegne af caerusx
        > Sendt: 23. januar 2012 09:57
        > Til: jslint_com@yahoogroups.com
        > Emne: [jslint] Re: Indentation quirk?
        >
        > Good morning!
        >
        > I was thinking about mixing open and compact forms. And I think
        > disallowing to use open inside compact and vice verse brings
        > inconveniences.
        >
        > It's fine for lint to use function parameters in compact form:
        >
        > func(1, 2, 3,
        > ~~~~~4, 5, 6, function () {});
        >
        > But when one parameter listed in compact form internally contains open
        > form, lint fails to validate:
        >
        > func(1, 2, 3,
        > ~~~~~4, 5, 6, function () {
        > ~~~~~});
        >
        > To pass validation, it's needed to rewrite outer block to open
        > form. Do you agree that code below, which is correct from lint point
        > of view, looks worse for a human?
        >
        > func(
        > ~~1,
        > ~~2,
        > ~~3,
        > ~~4,
        > ~~5,
        > ~~6,
        > ~~function () {
        > ~~}
        > );
        >
        > [Non-text portions of this message have been removed]
        >


        [Non-text portions of this message have been removed]
      • caerusx
        Hi Very often one line function does not fit in the same line with function keyword, so it s naturally to write it as open block. Consider:
        Message 3 of 7 , Jan 23, 2012
        • 0 Attachment
          Hi

          Very often one line function does not fit in the same line with
          function keyword, so it's naturally to write it as open block.

          Consider:

          some_function_with_the_long_name(arg1, arg2, arg3, arg4,
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~function () {
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~other_some_long_function(par1, par2);
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~});

          You just can't write lambda function in compact form, it does not
          fit. Rewriting code with named function, is less readable:

          var binder3;

          [... some lines of code ...]

          binder3 = function () {
          ~~other_some_long_function(par1, par2);
          };

          some_function_with_the_long_name(arg1, arg2, arg3, arg4, binder3);

          You have too look back, what binder3 is actually doing. Though it just
          a three lines upper, but it definitely takes more time to look back.

          More over, you have to split 'binder3' declaration and assignment. If
          you assign it in declaration statement, code become even more
          unreadable (you have to look back more code to find binder3
          definition).

          And by JSLint rules, you can't declare var just before calling
          'some_function_with_the_long_name', as you get an error: "Combine this
          with the previous 'var' statement.".

          You may object, that you may give a better name to 'binder3'. But any
          good name is not as expressive as code. You may give a name like
          'compare_tuples', but it does not express the all meaning (what
          relation is used for comparison, and what parts of tuple actually
          compared).

          --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@...> wrote:
          >
          > Hi
          >
          > The formatting problem you outlined had to do with how your code should be distributed over multiple lines, so it is not "just one line". If it was just one line jslints line breaking rules would hardly apply.
          >
          > I recommend that you improve the readability of your code because that makes it better code. That it also then happens to comply with the recommendations of jslint is an added bonus.
          >
          > /Jakob
          >
          > Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] På vegne af caerusx
          > Sendt: 23. januar 2012 12:38
          > Til: jslint_com@yahoogroups.com
          > Emne: SV: [jslint] Re: Indentation quirk?
          >
          >
          >
          >
          > Hi
          >
          > For one liners it's better to use lambda forms. No matter how
          > descriptive name is, better to see an actual code immediately, if it
          > just one line.
          >
          > Often lambda forms are used just to bind some parameters to existing
          > functions, or just to pass some expression (e.g. sort function), or
          > some simple filtering function. And it's weird to give an explicit
          > name to these one liners in language supporting lambda forms.
          >
          > It's just my opinion.
          >
          > Nevertheless, I don't think that it is a good idea to rewrite a
          > readable code to less readable just to pass a lint.
          >
          > Like in my other topic with cyclic dependent functions. It is possible
          > to work around lint requirement by splitting declarations of variable
          > and assignment to separate statements, but why to do this if it
          > actually complicates code.
          >
          > --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@> wrote:
          > >
          > > Good morning,
          > >
          > > Your problem seems to be your insistence on declaring a function inside a function call. This is much better (from a readability perspective):
          > >
          > > function myfunc() { � }
          > > func(1, 2, 3, 4, 5, 6, myfunc);
          > >
          > > Regards,
          > > Jakob
          > >
          > >
          > > Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] P� vegne af caerusx
          > > Sendt: 23. januar 2012 09:57
          > > Til: jslint_com@yahoogroups.com
          > > Emne: [jslint] Re: Indentation quirk?
          > >
          > > Good morning!
          > >
          > > I was thinking about mixing open and compact forms. And I think
          > > disallowing to use open inside compact and vice verse brings
          > > inconveniences.
          > >
          > > It's fine for lint to use function parameters in compact form:
          > >
          > > func(1, 2, 3,
          > > ~~~~~4, 5, 6, function () {});
          > >
          > > But when one parameter listed in compact form internally contains open
          > > form, lint fails to validate:
          > >
          > > func(1, 2, 3,
          > > ~~~~~4, 5, 6, function () {
          > > ~~~~~});
          > >
          > > To pass validation, it's needed to rewrite outer block to open
          > > form. Do you agree that code below, which is correct from lint point
          > > of view, looks worse for a human?
          > >
          > > func(
          > > ~~1,
          > > ~~2,
          > > ~~3,
          > > ~~4,
          > > ~~5,
          > > ~~6,
          > > ~~function () {
          > > ~~}
          > > );
          > >
          > > [Non-text portions of this message have been removed]
          > >
          >
          >
          > [Non-text portions of this message have been removed]
          >
        • Jakob Kruse
          I don’t see this going anywhere, but I’d like to point out that 1) A function call split over 3-4 lines is not a “one line function”. If you would
          Message 4 of 7 , Jan 23, 2012
          • 0 Attachment
            I don’t see this going anywhere, but I’d like to point out that

            1) A function call split over 3-4 lines is not a “one line function”. If you would like to make it one, stop declaring new functions inside the call.
            2) Why would you use “var” to first declare and then define a function. JavaScript has “function” for this purpose. Jslint does not complain about function statements separated from var statements.

            /Jakob


            Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] På vegne af caerusx
            Sendt: 23. januar 2012 13:36
            Til: jslint_com@yahoogroups.com
            Emne: SV: [jslint] Re: Indentation quirk?




            Hi

            Very often one line function does not fit in the same line with
            function keyword, so it's naturally to write it as open block.

            Consider:

            some_function_with_the_long_name(arg1, arg2, arg3, arg4,
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~function () {
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~other_some_long_function(par1, par2);
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~});

            You just can't write lambda function in compact form, it does not
            fit. Rewriting code with named function, is less readable:

            var binder3;

            [... some lines of code ...]

            binder3 = function () {
            ~~other_some_long_function(par1, par2);
            };

            some_function_with_the_long_name(arg1, arg2, arg3, arg4, binder3);

            You have too look back, what binder3 is actually doing. Though it just
            a three lines upper, but it definitely takes more time to look back.

            More over, you have to split 'binder3' declaration and assignment. If
            you assign it in declaration statement, code become even more
            unreadable (you have to look back more code to find binder3
            definition).

            And by JSLint rules, you can't declare var just before calling
            'some_function_with_the_long_name', as you get an error: "Combine this
            with the previous 'var' statement.".

            You may object, that you may give a better name to 'binder3'. But any
            good name is not as expressive as code. You may give a name like
            'compare_tuples', but it does not express the all meaning (what
            relation is used for comparison, and what parts of tuple actually
            compared).

            --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@...> wrote:
            >
            > Hi
            >
            > The formatting problem you outlined had to do with how your code should be distributed over multiple lines, so it is not "just one line". If it was just one line jslints line breaking rules would hardly apply.
            >
            > I recommend that you improve the readability of your code because that makes it better code. That it also then happens to comply with the recommendations of jslint is an added bonus.
            >
            > /Jakob
            >
            > Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] På vegne af caerusx
            > Sendt: 23. januar 2012 12:38
            > Til: jslint_com@yahoogroups.com
            > Emne: SV: [jslint] Re: Indentation quirk?
            >
            >
            >
            >
            > Hi
            >
            > For one liners it's better to use lambda forms. No matter how
            > descriptive name is, better to see an actual code immediately, if it
            > just one line.
            >
            > Often lambda forms are used just to bind some parameters to existing
            > functions, or just to pass some expression (e.g. sort function), or
            > some simple filtering function. And it's weird to give an explicit
            > name to these one liners in language supporting lambda forms.
            >
            > It's just my opinion.
            >
            > Nevertheless, I don't think that it is a good idea to rewrite a
            > readable code to less readable just to pass a lint.
            >
            > Like in my other topic with cyclic dependent functions. It is possible
            > to work around lint requirement by splitting declarations of variable
            > and assignment to separate statements, but why to do this if it
            > actually complicates code.
            >
            > --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@> wrote:
            > >
            > > Good morning,
            > >
            > > Your problem seems to be your insistence on declaring a function inside a function call. This is much better (from a readability perspective):
            > >
            > > function myfunc() { � }
            > > func(1, 2, 3, 4, 5, 6, myfunc);
            > >
            > > Regards,
            > > Jakob
            > >
            > >
            > > Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] P� vegne af caerusx
            > > Sendt: 23. januar 2012 09:57
            > > Til: jslint_com@yahoogroups.com
            > > Emne: [jslint] Re: Indentation quirk?
            > >
            > > Good morning!
            > >
            > > I was thinking about mixing open and compact forms. And I think
            > > disallowing to use open inside compact and vice verse brings
            > > inconveniences.
            > >
            > > It's fine for lint to use function parameters in compact form:
            > >
            > > func(1, 2, 3,
            > > ~~~~~4, 5, 6, function () {});
            > >
            > > But when one parameter listed in compact form internally contains open
            > > form, lint fails to validate:
            > >
            > > func(1, 2, 3,
            > > ~~~~~4, 5, 6, function () {
            > > ~~~~~});
            > >
            > > To pass validation, it's needed to rewrite outer block to open
            > > form. Do you agree that code below, which is correct from lint point
            > > of view, looks worse for a human?
            > >
            > > func(
            > > ~~1,
            > > ~~2,
            > > ~~3,
            > > ~~4,
            > > ~~5,
            > > ~~6,
            > > ~~function () {
            > > ~~}
            > > );
            > >
            > > [Non-text portions of this message have been removed]
            > >
            >
            >
            > [Non-text portions of this message have been removed]
            >


            [Non-text portions of this message have been removed]
          • caerusx
            1) I agree, it is not a real problem. When I validated my code I hit just several errors of such kind for 1000+ lines of code. And I was not able to find out
            Message 5 of 7 , Jan 23, 2012
            • 0 Attachment
              1) I agree, it is not a real problem. When I validated my code I hit
              just several errors of such kind for 1000+ lines of code. And I was
              not able to find out why JSLint suggests wrong indentation. Douglas
              post helped me much to find out why JSLint behaves so. It was not a
              problem for me to convert outer blocks to open form, and now my
              code is successfully passing validation.

              Actually with one exception (vars: true), but it just because my
              javascript editor (js-mode for emacs) can't parse multiline var
              statement. So I avoid it by splitting multiline var declarations to
              multiple subsequent one line declarations. Anyway UglifyJS will
              combine them together.

              So for now I just have not real but just technical interest, why
              open form inside compact form confuses JSLint.

              I don't think as it should be left as is. In test case I provided
              in first post JSLint suggests to use indisputably wrong
              indentation. And worse, after making changes which it wants, badly
              formatted javascript is passing validation.

              So as minimum, JSLint should not successfully validate wrongly
              formatted text. And if JSLint want to be kind, it would be nice if
              it produce human readable error that mixing of block forms is not
              allowed. ...Or it may allow to mix different forms, whatever author
              will decide.

              2) Thank you for pointing me that! (really)

              Long time ago, I've been reading that some buggy javascript
              implementations doesn't work well with nested functions in a way
              that nested functions actually declared in outer scope. And it is
              better to use var + lambda function, since every implementation
              work correctly in such case.

              I don't even recall where I've read this. I thought it was Google's
              JavaScript style guide, but now I see it actually encourage use of
              nested function. I guess either this recommendation is totally
              outdated or I've misread something. Now I will use nested functions :)


              --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@...> wrote:
              >
              > I don't see this going anywhere, but I'd like to point out that
              >
              > 1) A function call split over 3-4 lines is not a "one line function". If you would like to make it one, stop declaring new functions inside the call.
              > 2) Why would you use "var" to first declare and then define a function. JavaScript has "function" for this purpose. Jslint does not complain about function statements separated from var statements.
              >
              > /Jakob
              >
              >
              > Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] På vegne af caerusx
              > Sendt: 23. januar 2012 13:36
              > Til: jslint_com@yahoogroups.com
              > Emne: SV: [jslint] Re: Indentation quirk?
              >
              >
              >
              >
              > Hi
              >
              > Very often one line function does not fit in the same line with
              > function keyword, so it's naturally to write it as open block.
              >
              > Consider:
              >
              > some_function_with_the_long_name(arg1, arg2, arg3, arg4,
              > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~function () {
              > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~other_some_long_function(par1, par2);
              > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~});
              >
              > You just can't write lambda function in compact form, it does not
              > fit. Rewriting code with named function, is less readable:
              >
              > var binder3;
              >
              > [... some lines of code ...]
              >
              > binder3 = function () {
              > ~~other_some_long_function(par1, par2);
              > };
              >
              > some_function_with_the_long_name(arg1, arg2, arg3, arg4, binder3);
              >
              > You have too look back, what binder3 is actually doing. Though it just
              > a three lines upper, but it definitely takes more time to look back.
              >
              > More over, you have to split 'binder3' declaration and assignment. If
              > you assign it in declaration statement, code become even more
              > unreadable (you have to look back more code to find binder3
              > definition).
              >
              > And by JSLint rules, you can't declare var just before calling
              > 'some_function_with_the_long_name', as you get an error: "Combine this
              > with the previous 'var' statement.".
              >
              > You may object, that you may give a better name to 'binder3'. But any
              > good name is not as expressive as code. You may give a name like
              > 'compare_tuples', but it does not express the all meaning (what
              > relation is used for comparison, and what parts of tuple actually
              > compared).
              >
              > --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@> wrote:
              > >
              > > Hi
              > >
              > > The formatting problem you outlined had to do with how your code should be distributed over multiple lines, so it is not "just one line". If it was just one line jslints line breaking rules would hardly apply.
              > >
              > > I recommend that you improve the readability of your code because that makes it better code. That it also then happens to comply with the recommendations of jslint is an added bonus.
              > >
              > > /Jakob
              > >
              > > Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] På vegne af caerusx
              > > Sendt: 23. januar 2012 12:38
              > > Til: jslint_com@yahoogroups.com
              > > Emne: SV: [jslint] Re: Indentation quirk?
              > >
              > >
              > >
              > >
              > > Hi
              > >
              > > For one liners it's better to use lambda forms. No matter how
              > > descriptive name is, better to see an actual code immediately, if it
              > > just one line.
              > >
              > > Often lambda forms are used just to bind some parameters to existing
              > > functions, or just to pass some expression (e.g. sort function), or
              > > some simple filtering function. And it's weird to give an explicit
              > > name to these one liners in language supporting lambda forms.
              > >
              > > It's just my opinion.
              > >
              > > Nevertheless, I don't think that it is a good idea to rewrite a
              > > readable code to less readable just to pass a lint.
              > >
              > > Like in my other topic with cyclic dependent functions. It is possible
              > > to work around lint requirement by splitting declarations of variable
              > > and assignment to separate statements, but why to do this if it
              > > actually complicates code.
              > >
              > > --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@> wrote:
              > > >
              > > > Good morning,
              > > >
              > > > Your problem seems to be your insistence on declaring a function inside a function call. This is much better (from a readability perspective):
              > > >
              > > > function myfunc() { � }
              > > > func(1, 2, 3, 4, 5, 6, myfunc);
              > > >
              > > > Regards,
              > > > Jakob
              > > >
              > > >
              > > > Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] P� vegne af caerusx
              > > > Sendt: 23. januar 2012 09:57
              > > > Til: jslint_com@yahoogroups.com
              > > > Emne: [jslint] Re: Indentation quirk?
              > > >
              > > > Good morning!
              > > >
              > > > I was thinking about mixing open and compact forms. And I think
              > > > disallowing to use open inside compact and vice verse brings
              > > > inconveniences.
              > > >
              > > > It's fine for lint to use function parameters in compact form:
              > > >
              > > > func(1, 2, 3,
              > > > ~~~~~4, 5, 6, function () {});
              > > >
              > > > But when one parameter listed in compact form internally contains open
              > > > form, lint fails to validate:
              > > >
              > > > func(1, 2, 3,
              > > > ~~~~~4, 5, 6, function () {
              > > > ~~~~~});
              > > >
              > > > To pass validation, it's needed to rewrite outer block to open
              > > > form. Do you agree that code below, which is correct from lint point
              > > > of view, looks worse for a human?
              > > >
              > > > func(
              > > > ~~1,
              > > > ~~2,
              > > > ~~3,
              > > > ~~4,
              > > > ~~5,
              > > > ~~6,
              > > > ~~function () {
              > > > ~~}
              > > > );
              > > >
              > > > [Non-text portions of this message have been removed]
              > > >
              > >
              > >
              > > [Non-text portions of this message have been removed]
              > >
              >
              >
              > [Non-text portions of this message have been removed]
              >
            • caerusx
              Hi I rewrote all my functions declared as var to functions declared as function. (Thanks for giving me an insight that it s safe to declare nested functions).
              Message 6 of 7 , Jan 23, 2012
              • 0 Attachment
                Hi

                I rewrote all my functions declared as var to functions declared as
                function. (Thanks for giving me an insight that it's safe to declare
                nested functions). And I hit another problem: JSLint does not like
                'this' keyword inside function, it fails to validate function with an
                error "Strict violation".

                But function doesn't even supposed to access global 'this'
                object. It's just harmless jQuery callback which expects to be called
                in a context of DOM node.

                --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@...> wrote:
                >
                > I don't see this going anywhere, but I'd like to point out that
                >
                > 1) A function call split over 3-4 lines is not a "one line function". If you would like to make it one, stop declaring new functions inside the call.
                > 2) Why would you use "var" to first declare and then define a function. JavaScript has "function" for this purpose. Jslint does not complain about function statements separated from var statements.
                >
                > /Jakob
                >
                >
                > Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] På vegne af caerusx
                > Sendt: 23. januar 2012 13:36
                > Til: jslint_com@yahoogroups.com
                > Emne: SV: [jslint] Re: Indentation quirk?
                >
                >
                >
                >
                > Hi
                >
                > Very often one line function does not fit in the same line with
                > function keyword, so it's naturally to write it as open block.
                >
                > Consider:
                >
                > some_function_with_the_long_name(arg1, arg2, arg3, arg4,
                > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~function () {
                > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~other_some_long_function(par1, par2);
                > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~});
                >
                > You just can't write lambda function in compact form, it does not
                > fit. Rewriting code with named function, is less readable:
                >
                > var binder3;
                >
                > [... some lines of code ...]
                >
                > binder3 = function () {
                > ~~other_some_long_function(par1, par2);
                > };
                >
                > some_function_with_the_long_name(arg1, arg2, arg3, arg4, binder3);
                >
                > You have too look back, what binder3 is actually doing. Though it just
                > a three lines upper, but it definitely takes more time to look back.
                >
                > More over, you have to split 'binder3' declaration and assignment. If
                > you assign it in declaration statement, code become even more
                > unreadable (you have to look back more code to find binder3
                > definition).
                >
                > And by JSLint rules, you can't declare var just before calling
                > 'some_function_with_the_long_name', as you get an error: "Combine this
                > with the previous 'var' statement.".
                >
                > You may object, that you may give a better name to 'binder3'. But any
                > good name is not as expressive as code. You may give a name like
                > 'compare_tuples', but it does not express the all meaning (what
                > relation is used for comparison, and what parts of tuple actually
                > compared).
                >
                > --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@> wrote:
                > >
                > > Hi
                > >
                > > The formatting problem you outlined had to do with how your code should be distributed over multiple lines, so it is not "just one line". If it was just one line jslints line breaking rules would hardly apply.
                > >
                > > I recommend that you improve the readability of your code because that makes it better code. That it also then happens to comply with the recommendations of jslint is an added bonus.
                > >
                > > /Jakob
                > >
                > > Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] På vegne af caerusx
                > > Sendt: 23. januar 2012 12:38
                > > Til: jslint_com@yahoogroups.com
                > > Emne: SV: [jslint] Re: Indentation quirk?
                > >
                > >
                > >
                > >
                > > Hi
                > >
                > > For one liners it's better to use lambda forms. No matter how
                > > descriptive name is, better to see an actual code immediately, if it
                > > just one line.
                > >
                > > Often lambda forms are used just to bind some parameters to existing
                > > functions, or just to pass some expression (e.g. sort function), or
                > > some simple filtering function. And it's weird to give an explicit
                > > name to these one liners in language supporting lambda forms.
                > >
                > > It's just my opinion.
                > >
                > > Nevertheless, I don't think that it is a good idea to rewrite a
                > > readable code to less readable just to pass a lint.
                > >
                > > Like in my other topic with cyclic dependent functions. It is possible
                > > to work around lint requirement by splitting declarations of variable
                > > and assignment to separate statements, but why to do this if it
                > > actually complicates code.
                > >
                > > --- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@> wrote:
                > > >
                > > > Good morning,
                > > >
                > > > Your problem seems to be your insistence on declaring a function inside a function call. This is much better (from a readability perspective):
                > > >
                > > > function myfunc() { � }
                > > > func(1, 2, 3, 4, 5, 6, myfunc);
                > > >
                > > > Regards,
                > > > Jakob
                > > >
                > > >
                > > > Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] P� vegne af caerusx
                > > > Sendt: 23. januar 2012 09:57
                > > > Til: jslint_com@yahoogroups.com
                > > > Emne: [jslint] Re: Indentation quirk?
                > > >
                > > > Good morning!
                > > >
                > > > I was thinking about mixing open and compact forms. And I think
                > > > disallowing to use open inside compact and vice verse brings
                > > > inconveniences.
                > > >
                > > > It's fine for lint to use function parameters in compact form:
                > > >
                > > > func(1, 2, 3,
                > > > ~~~~~4, 5, 6, function () {});
                > > >
                > > > But when one parameter listed in compact form internally contains open
                > > > form, lint fails to validate:
                > > >
                > > > func(1, 2, 3,
                > > > ~~~~~4, 5, 6, function () {
                > > > ~~~~~});
                > > >
                > > > To pass validation, it's needed to rewrite outer block to open
                > > > form. Do you agree that code below, which is correct from lint point
                > > > of view, looks worse for a human?
                > > >
                > > > func(
                > > > ~~1,
                > > > ~~2,
                > > > ~~3,
                > > > ~~4,
                > > > ~~5,
                > > > ~~6,
                > > > ~~function () {
                > > > ~~}
                > > > );
                > > >
                > > > [Non-text portions of this message have been removed]
                > > >
                > >
                > >
                > > [Non-text portions of this message have been removed]
                > >
                >
                >
                > [Non-text portions of this message have been removed]
                >
              Your message has been successfully submitted and would be delivered to recipients shortly.