On Fri, Oct 30, 2009 at 2:22 AM, gMinuses <gminu...@gmail.com> wrote:
> It's very detailed, thank you for the demos! But I don't quite
> understand the purpose of them.

I was trying desperately to come up with some real-world use of your
suggestion, and noted that your example used callbacks, and I thought
you might want to use the technique to instrument your callback
methods in some manner.

> If you are saying $.map() shouldn't
> work on objects because wrapping functions is not a good practice,
> then $.map() should also not work on arrays. Here is why:
>
> // options now is a sequence
> var options = [ function() { this[1]() }}, function() { alert
> ('Oops') } ]

I'd contend that it's very difficult to see a real-world use of $.map
applied to functions.


> $.map() works on this "object", and it also causes the "problem" you
> have illustrated. Actually, I don't perceive it as a "problem". What
> you are doing is counting how many times the callback functions have
> been called. Since some callback functions will call another callback
> function, when three of them get called, it makes sense these callback
> functions have been called six times in total.

But "helper()" was not intended as a callback function.  It was an
implementation detail.  By accidentally mapping that function, we've
changed the semantics in a way we wouldn't have done if we'd chosen to
apply our transformation directly to the callbacks we cared about.

> Maybe I'm too dumb to get the essence of your demos, could you explain
> more to me? Thanks.

It's pretty clear you're not too dumb.  I'm just trying to figure out
how you'd want to use such an extended method.  The callbacks made me
wonder if this was the sort of detail you had in mind.

Cheers,

  -- Scott

--

You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to