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

Re: [jslint] Re: "unnamed" Parameter Option

Expand Messages
  • Doc Emmett Splendid
    I ve been wondering what the intent is on that as well. Perhaps the new recommended best practise is to pass in a single array argument in that case?
    Message 1 of 9 , Sep 20, 2011
    • 0 Attachment
      I've been wondering what the intent is on that as well. Perhaps the new recommended best practise is to pass in a single array argument in that case?


      ________________________________
      From: Robert Ferney <capnregex@...>
      To: jslint_com@yahoogroups.com
      Sent: Tuesday, 20 September 2011, 9:07
      Subject: Re: [jslint] Re: "unnamed" Parameter Option

      'arguments' is leaving the language?
      So, how do we handle functions that accept a variable number of arguments?

      - Robert Ferney




      On Tue, Sep 20, 2011 at 9:11 AM, Douglas Crockford <douglas@...>wrote:

      > **
      >
      >
      > --- In jslint_com@yahoogroups.com, "benxwhite" <ben.a.white@...> wrote:
      > >
      > > It would be nice if there was an option to disable the "Use a named
      > parameter" check.
      >
      > arguments will be leaving the language.
      > Start getting used to not using it.
      >

      >


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



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

      Yahoo! Groups Links



      [Non-text portions of this message have been removed]
    • Xavier MONTILLET
      Plus arguments is the only way to determine if an argument was omitted or if it was given the value undefined. Which should react differently on functions that
      Message 2 of 9 , Sep 20, 2011
      • 0 Attachment
        Plus arguments is the only way to determine if an argument was omitted or if
        it was given the value undefined. Which should react differently on
        functions that are both getters and setters.

        Sent from my smartphone.
        On Sep 20, 2011 7:56 PM, "Doc Emmett Splendid" <emmett.thesane@...>
        wrote:
        > I've been wondering what the intent is on that as well. Perhaps the new
        recommended best practise is to pass in a single array argument in that
        case?
        >
        >
        > ________________________________
        > From: Robert Ferney <capnregex@...>
        > To: jslint_com@yahoogroups.com
        > Sent: Tuesday, 20 September 2011, 9:07
        > Subject: Re: [jslint] Re: "unnamed" Parameter Option
        >
        > 'arguments' is leaving the language?
        > So, how do we handle functions that accept a variable number of arguments?
        >
        > - Robert Ferney
        >
        >
        >
        >
        > On Tue, Sep 20, 2011 at 9:11 AM, Douglas Crockford <douglas@...
        >wrote:
        >
        >> **
        >>
        >>
        >> --- In jslint_com@yahoogroups.com, "benxwhite" <ben.a.white@...> wrote:
        >> >
        >> > It would be nice if there was an option to disable the "Use a named
        >> parameter" check.
        >>
        >> arguments will be leaving the language.
        >> Start getting used to not using it.
        >>
        >>
        >>
        >
        >
        > [Non-text portions of this message have been removed]
        >
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >
        > [Non-text portions of this message have been removed]
        >


        [Non-text portions of this message have been removed]
      • Marcel Duran
        ... function f (o) { ....if (o && typeof o.foo !== undefined ) { ........// do something with o.foo ....} ....if (o && typeof o.bar !== undefined &&
        Message 3 of 9 , Sep 20, 2011
        • 0 Attachment
          On Tue, Sep 20, 2011 at 1:47 PM, Xavier MONTILLET wrote:

          > **
          >
          >
          > Plus arguments is the only way to determine if an argument was omitted or
          > if
          > it was given the value undefined. Which should react differently on
          > functions that are both getters and setters.
          >
          > Not necessarily, one can use object and arrays to mimmic arguments, e.g.:

          function f (o) {
          ....if (o && typeof o.foo !== 'undefined') {
          ........// do something with o.foo
          ....}
          ....if (o && typeof o.bar !== 'undefined' &&
          yourFavoriteArrayCheckFunction(o.bar)) {
          ........// iterate o.bar
          ....}
          }

          f({foo: true, bar: ['abc', 'def', 'ghi']});
          f({foo: true});
          f({bar: ['abc', 'def', 'ghi']});
          f({foo: true, bar: ['abc', 'def', 'ghi'], baz: 'something'});
          f({baz: 'something'});
          f({});
          f();

          --
          Marcel Duran


          [Non-text portions of this message have been removed]
        • sandyhead25
          Simple. Change the format of input to an object literal. Then you can have a variable number of named parameters. Consider the following: var args = {first:
          Message 4 of 9 , Sep 21, 2011
          • 0 Attachment
            Simple. Change the format of input to an object literal. Then you can have a variable number of named parameters. Consider the following:

            var args = {first: "x", second: "y", third: "z"},
            mycode = function (args) {
            //args.first === "x";
            };

            Here is an actual living example from a real application:
            https://github.com/austincheney/Pretty-Diff/blob/master/markup_beauty.js

            --- In jslint_com@yahoogroups.com, Robert Ferney <capnregex@...> wrote:
            >
            > 'arguments' is leaving the language?
            > So, how do we handle functions that accept a variable number of arguments?
            >
            > - Robert Ferney
            >
            >
            >
            >
            > On Tue, Sep 20, 2011 at 9:11 AM, Douglas Crockford <douglas@...>wrote:
            >
            > > **
            > >
            > >
            > > --- In jslint_com@yahoogroups.com, "benxwhite" <ben.a.white@> wrote:
            > > >
            > > > It would be nice if there was an option to disable the "Use a named
            > > parameter" check.
            > >
            > > arguments will be leaving the language.
            > > Start getting used to not using it.
            > >
            > >
            > >
            >
            >
            > [Non-text portions of this message have been removed]
            >
          • Xavier MONTILLET
            I don t get the point of removing arguments if it forces you to ask for an array as argument... ... [Non-text portions of this message have been removed]
            Message 5 of 9 , Sep 21, 2011
            • 0 Attachment
              I don't get the point of removing arguments if it forces you to ask for an
              array as argument...

              On Wed, Sep 21, 2011 at 7:04 PM, sandyhead25 <austin.cheney@...>wrote:

              > **
              >
              >
              > Simple. Change the format of input to an object literal. Then you can have
              > a variable number of named parameters. Consider the following:
              >
              > var args = {first: "x", second: "y", third: "z"},
              > mycode = function (args) {
              > //args.first === "x";
              > };
              >
              > Here is an actual living example from a real application:
              > https://github.com/austincheney/Pretty-Diff/blob/master/markup_beauty.js
              >
              >
              > --- In jslint_com@yahoogroups.com, Robert Ferney <capnregex@...> wrote:
              > >
              > > 'arguments' is leaving the language?
              > > So, how do we handle functions that accept a variable number of
              > arguments?
              > >
              > > - Robert Ferney
              > >
              > >
              > >
              > >
              > > On Tue, Sep 20, 2011 at 9:11 AM, Douglas Crockford <douglas@...>wrote:
              >
              > >
              > > > **
              > > >
              > > >
              > > > --- In jslint_com@yahoogroups.com, "benxwhite" <ben.a.white@> wrote:
              > > > >
              > > > > It would be nice if there was an option to disable the "Use a named
              > > > parameter" check.
              > > >
              > > > arguments will be leaving the language.
              > > > Start getting used to not using it.
              > > >
              > > >
              > > >
              > >
              > >
              > > [Non-text portions of this message have been removed]
              > >
              >
              >
              >


              [Non-text portions of this message have been removed]
            • sandyhead25
              Could you rephrase that? I am not sure what you are asking.
              Message 6 of 9 , Sep 22, 2011
              • 0 Attachment
                Could you rephrase that? I am not sure what you are asking.

                --- In jslint_com@yahoogroups.com, Xavier MONTILLET <xavierm02.net@...> wrote:
                >
                > I don't get the point of removing arguments if it forces you to ask for an
                > array as argument...
                >
                > On Wed, Sep 21, 2011 at 7:04 PM, sandyhead25 <austin.cheney@...>wrote:
                >
                > > **
                > >
                > >
                > > Simple. Change the format of input to an object literal. Then you can have
                > > a variable number of named parameters. Consider the following:
                > >
                > > var args = {first: "x", second: "y", third: "z"},
                > > mycode = function (args) {
                > > //args.first === "x";
                > > };
                > >
                > > Here is an actual living example from a real application:
                > > https://github.com/austincheney/Pretty-Diff/blob/master/markup_beauty.js
                > >
              Your message has been successfully submitted and would be delivered to recipients shortly.