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

2861Re: [jslint] Re: Early Unused Arguments

Expand Messages
  • Max
    Apr 28, 2012
    • 0 Attachment
      You might want to spend some time on Google, looking up functional
      programming, what it is, what it is good for. Discover its strengths.
      There is a whole lot more to functional programming than 'just a bit of
      sloppiness created by some shoddy frameworks, or some lazy programmers'.
      You might find there is a new wonderful whole world to explore if you
      simply allow yourself. :-)

      On 4/28/2012 4:17 AM, sandyhead25 wrote:
      > While I understand the passing of functions as arguments of other
      > functions is a common style in many frameworks it is extremely sloppy.
      > This is an unnecessary complexity. You can easily avoid such
      > complicated problems by not writing code this way.
      > To your point however, there is a use case that does reflect your
      > concern in a way that is difficult to avoid. This one case is the
      > implied event argument of functions in web browsers other than IE
      > where these functions are directly referenced from that event. In this
      > case the event is passed as an argument so that it can be nullified
      > when so requested or can be tested to determine the event type. In
      > this case the passing of actual arguments can become unnecessarily
      > complicated.
      > If the described complication does not match the problems you are
      > encountering then write you code in a less complicated way. There is
      > never a good reason to pass a function as an argument to another
      > function except in reference only to test for type or depth of
      > instantiation, but this is a rare edge case. To pass a function by
      > reference only treat it like any other variable as a name with the
      > parens or arguments. I can say there is never a valid use case because
      > a function can also be defined internally to its parent or referenced
      > via closure, which accomplish the same execution. The difference is
      > that instantiation is separated from declaration.
      > The reason why many frameworks use this sloppiness is because they are
      > attempting to provide a means of shorthanded code instead of writing
      > something simple. That is a vanity concern and not an execution
      > concern. While this is an extraordinarily weak argument completely
      > lacking of any rational merit consider its audience.
      > Austin
      > --- In jslint_com@yahoogroups.com
      > <mailto:jslint_com%40yahoogroups.com>, "benquarmby" <ben.quarmby@...>
      > wrote:
      > >
      > > I realize the topic of unused arguments has been discussed before,
      > but I wanted to raise it again with a suggested alternative behavior.
      > >
      > > When creating callbacks / event handler functions for an API, you
      > rarely have control over the expected number of arguments, nor their
      > order. While it would be great if all these APIs passed a single
      > object as the first argument, the reality is that they usually pass up
      > to three separate arguments instead.
      > >
      > > In that case, if you only use the second of those three, the first
      > must still be provided. JSLint naturally warns about these early
      > unused arguments. At the moment the team I work with manually adds
      > comments to avoid warnings, but it quickly becomes unwieldy.
      > >
      > > So, I'd like to know your thoughts on allowing unused arguments
      > before a used one, but not after. In other words, the following would
      > not cause a warning:
      > >
      > > MY_API.binder(someElement, 'click', function (a, b) {
      > > iAmUsing(b);
      > > });
      > >
      > > The following would raise an "Unused Variable 'c'" warning:
      > >
      > > MY_API.binder(someElement, 'click', function (a, b, c) {
      > > iAmUsing(b);
      > > });
      > >
      > > Thoughts? Could it be a new toleration?
      > >
    • Show all 11 messages in this topic