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

Block-comment trick stops JSLINT

Expand Messages
  • montago_2004
    Block commenting can be used to switch between two similar functionalities - then by simply removing or adding a * in the first /*/ you switch the two...
    Message 1 of 10 , Jul 31 5:18 AM
    • 0 Attachment
      Block commenting can be used to switch between two similar
      functionalities - then by simply removing or adding a '*' in the first
      '/*/' you switch the two...

      JSLINT is however not able to parse it (nor is my Editor ;-)... )
      Visual Studio 05/08 and other nice tools understand this trick though.

      //--------------------------

      /**/
      function DoSomething(){
      //this way
      }
      /*/
      function DoSomething(){
      //another way
      }
      /**/
    • Michael Newton
      ... ECMA says Comments can be either single or multi-line. Multi-line comments cannot nest.
      Message 2 of 10 , Jul 31 1:53 PM
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "montago_2004" <mdk@...> wrote:
        >
        >
        > Block commenting can be used to switch between two similar
        > functionalities - then by simply removing or adding a '*' in the first
        > '/*/' you switch the two...
        >
        > JSLINT is however not able to parse it (nor is my Editor ;-)... )
        > Visual Studio 05/08 and other nice tools understand this trick though.
        >
        > //--------------------------
        >
        > /**/
        > function DoSomething(){
        > //this way
        > }
        > /*/
        > function DoSomething(){
        > //another way
        > }
        > /**/
        >

        ECMA says "Comments can be either single or multi-line. Multi-line
        comments cannot nest."
      • Douglas Crockford
        ... That is a terrible practice. It is easy enough to program computers to do useful things. You shouldn t need to rely on silly tricks.
        Message 3 of 10 , Jul 31 4:57 PM
        • 0 Attachment
          --- In jslint_com@yahoogroups.com, "montago_2004" <mdk@...> wrote:

          > Block commenting can be used to switch between two similar
          > functionalities - then by simply removing or adding a '*' in the first
          > '/*/' you switch the two...

          That is a terrible practice. It is easy enough to program computers to
          do useful things. You shouldn't need to rely on silly tricks.
        • montago_2004
          ... no.. its very good practise to code and debug... do you disagree ? this trick relies on a proper parser. I ve made it work in my Editor... also works in
          Message 4 of 10 , Aug 5, 2008
          • 0 Attachment
            --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...>
            wrote:
            >
            > --- In jslint_com@yahoogroups.com, "montago_2004" <mdk@> wrote:
            >
            > > Block commenting can be used to switch between two similar
            > > functionalities - then by simply removing or adding a '*' in the first
            > > '/*/' you switch the two...
            >
            > That is a terrible practice. It is easy enough to program computers to
            > do useful things. You shouldn't need to rely on silly tricks.
            >

            no.. its very good practise to code and debug...
            do you disagree ?

            this trick relies on a proper parser.

            I've made it work in my Editor...
            also works in Visual Studio (any version), Notepad++, Dreamweaver and
            whatever...

            its a bug in JSLint, admit it...
          • Klemen Slavič
            IMHO, I don t think it s the domain of JSlint to handle these kind of comments, since the output of this algorithm is supposed to be clean code that is meant
            Message 5 of 10 , Aug 6, 2008
            • 0 Attachment
              IMHO, I don't think it's the domain of JSlint to handle these kind of comments, since the output of this algorithm is supposed to be clean code that is meant to be used in the wild - having those kinds of comments still inside production code is more a sign of an unfinished product than a lacking in JSlint's features.

              I'd suggest you ignore those errors when debugging and remove them upon delivery - having an option to ignore those comments could lead to code leak in the final product, like leftover dead commented code.

              2008/8/6 montago_2004 <mdk@...>


              no.. its very good practise to code and debug...
              do you disagree ?

              this trick relies on a proper parser.

              I've made it work in my Editor...
              also works in Visual Studio (any version), Notepad++, Dreamweaver and
              whatever...

              its a bug in JSLint, admit it...

            • montago_2004
              ... code ... comments still ... code leak ... If only JSLint would report it as an Error ... JSLint stops completely, so its not even possible to simply
              Message 6 of 10 , Aug 6, 2008
              • 0 Attachment
                --- In jslint_com@yahoogroups.com, "Klemen Slavič" <krof.drakula@...>
                wrote:
                >
                > IMHO, I don't think it's the domain of JSlint to handle these kind of
                > comments, since the output of this algorithm is supposed to be clean
                code
                > that is meant to be used in the wild - having those kinds of
                comments still
                > inside production code is more a sign of an unfinished product than a
                > lacking in JSlint's features.
                >
                > I'd suggest you ignore those errors when debugging and remove them upon
                > delivery - having an option to ignore those comments could lead to
                code leak
                > in the final product, like leftover dead commented code.

                If only JSLint would report it as an "Error"... JSLint stops
                completely, so its not even possible to simply ignore the error...

                If JSLint isn't supposed to be used WHILE coding, then what good is it
                ?... if you have a finished product which works perfectly... then
                theres not really a point in running JSLint on the code, unless you
                are a code-perfectionist who looooves beautiful code.

                the jQuery team gave up on JSLint because it actually introduced bad
                code behavior or unusual code :
                - http://dean.edwards.name/weblog/2006/06/jslint/
                -
                http://groups.google.com/group/jquery-en/browse_thread/thread/e53f483dd67e4d08/f72f7832ead80dfb?lnk=gst&q=JSLint#f72f7832ead80dfb


                the point of the discussion is that JSlint may be used to "validate"
                code - but only in a specific direction: towards Douglas favorite
                code-style

                anyhoo -- i think its more important that JSLint has a good and big
                support for testing code - and then disable whatever isn't suited for
                the people using it.


                and back... The /*/ trick is meant for debugging -- if JSLint isn't
                meant for people debugging, i can't use it.
              • Douglas Crockford
                ... upon ... http://groups.google.com/group/jquery-en/browse_thread/thread/e53f483dd67e4d08/f72f7832ead80dfb?lnk=gst&q=JSLint#f72f7832ead80dfb ... JSLint stops
                Message 7 of 10 , Aug 6, 2008
                • 0 Attachment
                  --- In jslint_com@yahoogroups.com, "montago_2004" <mdk@...> wrote:
                  >
                  > --- In jslint_com@yahoogroups.com, "Klemen Slavič" <krof.drakula@>
                  > wrote:
                  > >
                  > > IMHO, I don't think it's the domain of JSlint to handle these kind of
                  > > comments, since the output of this algorithm is supposed to be clean
                  > code
                  > > that is meant to be used in the wild - having those kinds of
                  > comments still
                  > > inside production code is more a sign of an unfinished product than a
                  > > lacking in JSlint's features.
                  > >
                  > > I'd suggest you ignore those errors when debugging and remove them
                  upon
                  > > delivery - having an option to ignore those comments could lead to
                  > code leak
                  > > in the final product, like leftover dead commented code.
                  >
                  > If only JSLint would report it as an "Error"... JSLint stops
                  > completely, so its not even possible to simply ignore the error...
                  >
                  > If JSLint isn't supposed to be used WHILE coding, then what good is it
                  > ?... if you have a finished product which works perfectly... then
                  > theres not really a point in running JSLint on the code, unless you
                  > are a code-perfectionist who looooves beautiful code.
                  >
                  > the jQuery team gave up on JSLint because it actually introduced bad
                  > code behavior or unusual code :
                  > - http://dean.edwards.name/weblog/2006/06/jslint/
                  > -
                  >
                  http://groups.google.com/group/jquery-en/browse_thread/thread/e53f483dd67e4d08/f72f7832ead80dfb?lnk=gst&q=JSLint#f72f7832ead80dfb
                  >
                  >
                  > the point of the discussion is that JSlint may be used to "validate"
                  > code - but only in a specific direction: towards Douglas favorite
                  > code-style
                  >
                  > anyhoo -- i think its more important that JSLint has a good and big
                  > support for testing code - and then disable whatever isn't suited for
                  > the people using it.
                  >
                  >
                  > and back... The /*/ trick is meant for debugging -- if JSLint isn't
                  > meant for people debugging, i can't use it.

                  JSLint stops because it sees comments that are nested. That is usually
                  an indication of a serious coding error. In the face of such errors,
                  JSLint stops.

                  You should not be employing coding patterns that depend on coding errors.

                  Edwards was doing something badly, and rather than understand the
                  correct thing, I attempted something even worse as a workaround. I
                  think he has since gotten smarter.

                  JSLint is a code quality tool. If quality is not a priority for you,
                  then don't use it.
                • montago_2004
                  /* Douglas ain t smart. */ Douglas is smart. //------------------------- Q: which of those two statements are more accurate ? A: the one, which is not a
                  Message 8 of 10 , Aug 6, 2008
                  • 0 Attachment
                    /*
                    Douglas ain't smart.
                    */

                    Douglas is smart.

                    //-------------------------

                    Q: which of those two statements are more accurate ?

                    A: the one, which is not a comment, because its removed by the compiler.


                    so my point is... should JSlint care about text inside comments ?
                    I'm just asking.
                  • Douglas Crockford
                    ... Yes it should, because sometimes syntax errors are hidden in comments. Again, I caution you to avoid programming conventions that depend on intentional
                    Message 9 of 10 , Aug 6, 2008
                    • 0 Attachment
                      --- In jslint_com@yahoogroups.com, "montago_2004" <mdk@...> wrote:
                      > so my point is... should JSlint care about text inside comments ?

                      Yes it should, because sometimes syntax errors are hidden in comments.
                      Again, I caution you to avoid programming conventions that depend on
                      intentional errors.
                    • Paul de Jong
                      ... For the reasoning behind removing the comments may I recommend: JavaScript: The Good Parts, Douglas Crockford, O Reilly, 2008.
                      Message 10 of 10 , Aug 6, 2008
                      • 0 Attachment
                        On Wed, Aug 6, 2008 at 12:46 PM, montago_2004 <mdk@...> wrote:
                        > /*
                        > Douglas ain't smart.
                        > */
                        >
                        > Douglas is smart.
                        >
                        > //-------------------------
                        >
                        > Q: which of those two statements are more accurate ?
                        >
                        > A: the one, which is not a comment, because its removed by the compiler.
                        >
                        > so my point is... should JSlint care about text inside comments ?
                        > I'm just asking.

                        For the reasoning behind removing the comments may I recommend:
                        JavaScript: The Good Parts, Douglas Crockford, O'Reilly, 2008.
                      Your message has been successfully submitted and would be delivered to recipients shortly.