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

/*jslint is seen as a reserved word

Expand Messages
  • Woomla
    Hi, This code gives a message: Problem at line 5 character 9: Expected an identifier and instead saw /*jslint (a reserved word). That s correct and it s my
    Message 1 of 8 , Mar 4, 2011
    View Source
    • 0 Attachment
      Hi,

      This code gives a message: Problem at line 5 character 9: Expected an identifier and instead saw '/*jslint' (a reserved word). That's correct and it's my intention to allow bitwise operator &.


      (function () {
      "use strict";

      String.implement({
      /*jslint bitwise: false*/
      getByteAt: function (index) {
      return this.charCodeAt(index) & 0xFF;
      }
      });
      }());

      If I move the /*jslint before String.implement, it is ok. But I guess it should be fine on the line in this example as well, shouldn't it?
    • Woomla
      You have to reply and edit the code there because the html strips the spaces. Or get the code from: http://jsfiddle.net/5WLp8/. Copy and paste it into
      Message 2 of 8 , Mar 4, 2011
      View Source
      • 0 Attachment
        You have to reply and edit the code there because the html strips the spaces. Or get the code from: http://jsfiddle.net/5WLp8/. Copy and paste it into jslint.com and select the good parts.

        --- In jslint_com@yahoogroups.com, "Woomla" <woomla@...> wrote:
        >
        > Hi,
        >
        > This code gives a message: Problem at line 5 character 9: Expected an identifier and instead saw '/*jslint' (a reserved word). That's correct and it's my intention to allow bitwise operator &.
        >
        >
        > (function () {
        > "use strict";
        >
        > String.implement({
        > /*jslint bitwise: false*/
        > getByteAt: function (index) {
        > return this.charCodeAt(index) & 0xFF;
        > }
        > });
        > }());
        >
        > If I move the /*jslint before String.implement, it is ok. But I guess it should be fine on the line in this example as well, shouldn't it?
        >
      • Douglas Crockford
        ... No it shouldn t. JSLint allows those directives at statement position only.
        Message 3 of 8 , Mar 4, 2011
        View Source
        • 0 Attachment
          --- In jslint_com@yahoogroups.com, "Woomla" <woomla@...> wrote:
          > This code gives a message: Problem at line 5 character 9: Expected an identifier and instead saw '/*jslint' (a reserved word). That's correct and it's my intention to allow bitwise operator &.
          >
          >
          > (function () {
          > "use strict";
          >
          > String.implement({
          > /*jslint bitwise: false*/
          > getByteAt: function (index) {
          > return this.charCodeAt(index) & 0xFF;
          > }
          > });
          > }());
          >
          > If I move the /*jslint before String.implement, it is ok. But I guess it should be fine on the line in this example as well, shouldn't it?


          No it shouldn't. JSLint allows those directives at statement position only.
        • Joshua Bell
          On Fri, Mar 4, 2011 at 8:29 AM, Douglas Crockford ... Does the jslint directive apply within a lexical scope, or does it function like
          Message 4 of 8 , Mar 4, 2011
          View Source
          • 0 Attachment
            On Fri, Mar 4, 2011 at 8:29 AM, Douglas Crockford <douglas@...>
            wrote:
            >
            >
            > No it shouldn't. JSLint allows those directives at statement position only.
            >

            Does the jslint directive apply within a lexical scope, or does it function
            like a pre-processor directive irrespective of lexical structure?

            i.e. which should be used:

            function twiddle(a, b) {
            /*jslint bitwise: false*/ // allow bitwise operators for this lexical
            scope
            return a & b;
            }
            // bitwise option implicitly back to default for rest of file

            or:

            function twiddle(a, b) {
            /*jslint bitwise: false*/ // allow bitwise operators
            return a & b;
            /*jslint bitwise: true*/ // disallow bitwise operators for rest of file
            }

            I had been assuming the latter, but I'd be quite happy if it were the
            former.


            [Non-text portions of this message have been removed]
          • abyssoft@ymail.com
            Neither of those are lexically correct however /*jslint bitwise: false*/ // allow bitwise operators function twiddle(a, b) { return a & b; } /*jslint bitwise:
            Message 5 of 8 , Mar 4, 2011
            View Source
            • 0 Attachment
              Neither of those are lexically correct
              however

              /*jslint bitwise: false*/ // allow bitwise operators
              function twiddle(a, b) {
              return a & b;
              }
              /*jslint bitwise: true*/ // disallow bitwise operators for rest of file

              --- In jslint_com@yahoogroups.com, Joshua Bell <josh@...> wrote:
              >
              > On Fri, Mar 4, 2011 at 8:29 AM, Douglas Crockford <douglas@...>
              > wrote:
              > >
              > >
              > > No it shouldn't. JSLint allows those directives at statement position only.
              > >
              >
              > Does the jslint directive apply within a lexical scope, or does it function
              > like a pre-processor directive irrespective of lexical structure?
              >
              > i.e. which should be used:
              >
              > function twiddle(a, b) {
              > /*jslint bitwise: false*/ // allow bitwise operators for this lexical
              > scope
              > return a & b;
              > }
              > // bitwise option implicitly back to default for rest of file
              >
              > or:
              >
              > function twiddle(a, b) {
              > /*jslint bitwise: false*/ // allow bitwise operators
              > return a & b;
              > /*jslint bitwise: true*/ // disallow bitwise operators for rest of file
              > }
              >
              > I had been assuming the latter, but I'd be quite happy if it were the
              > former.
              >
              >
              > [Non-text portions of this message have been removed]
              >
            • abyssoft@ymail.com
              is. Hate when I forget to finish a though. Thats what I get for multitasking 8-/
              Message 6 of 8 , Mar 4, 2011
              View Source
              • 0 Attachment
                is.

                Hate when I forget to finish a though.

                Thats what I get for multitasking 8-/

                --- In jslint_com@yahoogroups.com, "abyssoft@..." <abyssoft@...> wrote:
                >
                >
                >
                >
                >
                >
                >
                > Neither of those are lexically correct
                > however
                >
                > /*jslint bitwise: false*/ // allow bitwise operators
                > function twiddle(a, b) {
                > return a & b;
                > }
                > /*jslint bitwise: true*/ // disallow bitwise operators for rest of file
                >
                > --- In jslint_com@yahoogroups.com, Joshua Bell <josh@> wrote:
                > >
                > > On Fri, Mar 4, 2011 at 8:29 AM, Douglas Crockford <douglas@>
                > > wrote:
                > > >
                > > >
                > > > No it shouldn't. JSLint allows those directives at statement position only.
                > > >
                > >
                > > Does the jslint directive apply within a lexical scope, or does it function
                > > like a pre-processor directive irrespective of lexical structure?
                > >
                > > i.e. which should be used:
                > >
                > > function twiddle(a, b) {
                > > /*jslint bitwise: false*/ // allow bitwise operators for this lexical
                > > scope
                > > return a & b;
                > > }
                > > // bitwise option implicitly back to default for rest of file
                > >
                > > or:
                > >
                > > function twiddle(a, b) {
                > > /*jslint bitwise: false*/ // allow bitwise operators
                > > return a & b;
                > > /*jslint bitwise: true*/ // disallow bitwise operators for rest of file
                > > }
                > >
                > > I had been assuming the latter, but I'd be quite happy if it were the
                > > former.
                > >
                > >
                > > [Non-text portions of this message have been removed]
                > >
                >
              • Douglas Crockford
                ... It acts as a pragma. I do not recommend this use. I regret having allowed it.
                Message 7 of 8 , Mar 4, 2011
                View Source
                • 0 Attachment
                  --- In jslint_com@yahoogroups.com, Joshua Bell <josh@...> wrote:
                  >
                  > On Fri, Mar 4, 2011 at 8:29 AM, Douglas Crockford <douglas@...>
                  > wrote:
                  > >
                  > >
                  > > No it shouldn't. JSLint allows those directives at statement position only.
                  > >
                  >
                  > Does the jslint directive apply within a lexical scope, or does it function
                  > like a pre-processor directive irrespective of lexical structure?
                  >
                  > i.e. which should be used:
                  >
                  > function twiddle(a, b) {
                  > /*jslint bitwise: false*/ // allow bitwise operators for this lexical
                  > scope
                  > return a & b;
                  > }


                  It acts as a pragma. I do not recommend this use. I regret having allowed it.
                • Zhami
                  Woomla: You could also move the pragma further in (rather than out) In my code, I disable such pragma immediately after the line of code I need it suspended
                  Message 8 of 8 , Mar 5, 2011
                  View Source
                  • 0 Attachment
                    Woomla: You could also move the pragma further in (rather than out)

                    In my code, I disable such pragma immediately after the line of code I need it suspended for.

                    Douglas: In the following, JSLint reports the second appearance of the pragma as being unreachable, which is true were it executable (curiously though, the effect of that pragma is put into effect).

                    (function () {
                    "use strict";

                    String.implement({
                    getByteAt: function (index) {
                    /*jslint bitwise: false*/
                    return this.charCodeAt(index) & 0xFF;
                    /*jslint bitwise: true*/
                    }
                    });
                    }());


                    --- In jslint_com@yahoogroups.com, "Woomla" <woomla@...> wrote:
                    >
                    > Hi,
                    >
                    > This code gives a message: Problem at line 5 character 9: Expected an identifier and instead saw '/*jslint' (a reserved word). That's correct and it's my intention to allow bitwise operator &.
                    >
                    >
                    > (function () {
                    > "use strict";
                    >
                    > String.implement({
                    > /*jslint bitwise: false*/
                    > getByteAt: function (index) {
                    > return this.charCodeAt(index) & 0xFF;
                    > }
                    > });
                    > }());
                    >
                    > If I move the /*jslint before String.implement, it is ok. But I guess it should be fine on the line in this example as well, shouldn't it?
                    >
                  Your message has been successfully submitted and would be delivered to recipients shortly.