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

Re: question about strict mode violation

Expand Messages
  • walfisch_in_the_sea
    ... Sorry, I didn t mean the linting. Is it valid ecmascript5 to switch from non-strict mode to strict mode within one file? That might happen by concatenating
    Message 1 of 5 , Jan 10, 2010
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
      >
      > --- In jslint_com@yahoogroups.com, "walfisch_in_the_sea" <christian.wirkus@> wrote:
      > >
      > > Hi.
      > > In production mode I concatenate my files.
      > > What if one of them is not in strict mode?
      > >
      > > So the result is:
      > >
      > > //none-strict-mode-ecmascript
      > > "use strict";
      > > //strict-mode-ecmascript
      > >
      > > Is that allowed?
      >
      > No. You should be linting the individual files.
      >

      Sorry, I didn't mean the linting. Is it valid ecmascript5 to switch from non-strict mode to strict mode within one file? That might happen by concatenating of a non-strict library and a "use strict" file. Worst case would be that future browser assume the whole file to be strict and thereby break the code.
      I wondered because everybody is saying today "use as few files as possible or you and your site will be lame".

      Sorry, that is not really a JSLint question.
    • Douglas Crockford
      ... The use strict ; pragma is only meaningful at the first statement of a file or first statement of a function body. Anywhere else it is just a useless
      Message 2 of 5 , Jan 10, 2010
      • 0 Attachment
        > Is it valid ecmascript5 to switch from non-strict mode to strict mode within one file? That might happen by concatenating of a non-strict library and a "use strict" file. Worst case would be that future browser assume the whole file to be strict and thereby break the code.
        > I wondered because everybody is saying today "use as few files as possible or you and your site will be lame".


        The "use strict"; pragma is only meaningful at the first statement of a file or first statement of a function body. Anywhere else it is just a useless expression statement and is ignored.
      • walfisch_in_the_sea
        Ah, thanks.
        Message 3 of 5 , Jan 11, 2010
        • 0 Attachment
          Ah, thanks.


          --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
          >
          > > Is it valid ecmascript5 to switch from non-strict mode to strict mode within one file? That might happen by concatenating of a non-strict library and a "use strict" file. Worst case would be that future browser assume the whole file to be strict and thereby break the code.
          > > I wondered because everybody is saying today "use as few files as possible or you and your site will be lame".
          >
          >
          > The "use strict"; pragma is only meaningful at the first statement of a file or first statement of a function body. Anywhere else it is just a useless expression statement and is ignored.
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.