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

RE: [jslint] Method operations on string literals in concatenation chains

Expand Messages
  • Luke Page
    You have to be concatenating a massive number of strings for that to make real world difference. Otherwise it is just needlessly complicating things. Ideally
    Message 1 of 8 , Jul 7 12:53 AM
    • 0 Attachment
      You have to be concatenating a massive number of strings for that to make
      real world difference. Otherwise it is just needlessly complicating things.

      Ideally for best clarity and separation your html template will be defined
      separate from your template mechanism and separate from logic generating
      your replacement values.

      Partly because of this I can't think of any times I've seen a bug along
      these lines. The most common intention in code I've seen would be the case
      you don't want! I would rather be forced to write
      A = "b"+"c";
      A = A.x();

      For your case and I certainly don't think it looks nice having to write

      A = "b" + ("c").x();

      You might as well require every expression have brackets to ensure the
      programmer doesn't have a bad knowledge of operator precedence (which I
      already do in non obvious cases). I'd consider this a reasonably obvious
      case.

      What do people think about operator precedence / bracket usage in general -
      are there any rules everyone agrees would be useful?
      On 7 Jul 2011 07:49, "Rob Richardson" <erobrich@...> wrote:


      [Non-text portions of this message have been removed]
    • Erik Eckhardt
      Why concatenate string literals together, anyway? A = a + b + c .replace(); seems like it simply ought to be: A = abc .replace(); Perhaps it is
      Message 2 of 8 , Jul 7 8:37 AM
      • 0 Attachment
        Why concatenate string literals together, anyway?

        A = "a" + "b" + "c".replace();

        seems like it simply ought to be:

        A = "abc".replace();

        Perhaps it is multi-line strings that introduce bugs more than improper
        parentheses for the replace function.

        On Thu, Jul 7, 2011 at 12:53 AM, Luke Page <luke.a.page@...> wrote:

        > **
        >
        >
        > You have to be concatenating a massive number of strings for that to make
        > real world difference. Otherwise it is just needlessly complicating things.
        >
        > Ideally for best clarity and separation your html template will be defined
        > separate from your template mechanism and separate from logic generating
        > your replacement values.
        >
        > Partly because of this I can't think of any times I've seen a bug along
        > these lines. The most common intention in code I've seen would be the case
        > you don't want! I would rather be forced to write
        > A = "b"+"c";
        > A = A.x();
        >
        > For your case and I certainly don't think it looks nice having to write
        >
        > A = "b" + ("c").x();
        >
        > You might as well require every expression have brackets to ensure the
        > programmer doesn't have a bad knowledge of operator precedence (which I
        > already do in non obvious cases). I'd consider this a reasonably obvious
        > case.
        >
        > What do people think about operator precedence / bracket usage in general -
        > are there any rules everyone agrees would be useful?
        >
        > On 7 Jul 2011 07:49, "Rob Richardson" <erobrich@...> wrote:
        >
        > [Non-text portions of this message have been removed]
        >
        >
        >


        [Non-text portions of this message have been removed]
      • Emmett Pickerel
        Most recently, I ve been doing a lot of embed codes (object + params + embed). I break them into multiple lines to aid readability, as they tend to be quite
        Message 3 of 8 , Jul 7 10:48 AM
        • 0 Attachment
          Most recently, I've been doing a lot of embed codes (object + params + embed). I break them into multiple lines to aid readability, as they tend to be quite long and would wrap in odd places.


          ----- Original Message -----
          From: Erik Eckhardt <erik@...>
          To: jslint_com@yahoogroups.com
          Cc:
          Sent: Thursday, 7 July 2011, 8:37
          Subject: Re: [jslint] Method operations on string literals in concatenation chains

          Why concatenate string literals together, anyway?

          A = "a" + "b" + "c".replace();

          seems like it simply ought to be:

          A = "abc".replace();

          Perhaps it is multi-line strings that introduce bugs more than improper
          parentheses for the replace function.

          On Thu, Jul 7, 2011 at 12:53 AM, Luke Page <luke.a.page@...> wrote:

          > **
          >
          >
          > You have to be concatenating a massive number of strings for that to make
          > real world difference. Otherwise it is just needlessly complicating things.
          >
          > Ideally for best clarity and separation your html template will be defined
          > separate from your template mechanism and separate from logic generating
          > your replacement values.
          >
          > Partly because of this I can't think of any times I've seen a bug along
          > these lines. The most common intention in code I've seen would be the case
          > you don't want! I would rather be forced to write
          > A = "b"+"c";
          > A = A.x();
          >
          > For your case and I certainly don't think it looks nice having to write
          >
          > A = "b" + ("c").x();
          >
          > You might as well require every expression have brackets to ensure the
          > programmer doesn't have a bad knowledge of operator precedence (which I
          > already do in non obvious cases). I'd consider this a reasonably obvious
          > case.
          >
          > What do people think about operator precedence / bracket usage in general -
          > are there any rules everyone agrees would be useful?
          >
          > On 7 Jul 2011 07:49, "Rob Richardson" <erobrich@...> wrote:
          >
          > [Non-text portions of this message have been removed]
          >

          >


          [Non-text portions of this message have been removed]



          ------------------------------------

          Yahoo! Groups Links
        Your message has been successfully submitted and would be delivered to recipients shortly.