You can use this syntax:

function compose (fn1, fn2) {
 // returns a function that calls fn1 with the result of fn2
 function inner() { 
  return fn1( fn2.apply(null, arguments)) 
 }

 return inner;
}

This is perfectly valid javascript and will do exactly what you want, while 
providing a name for the inner function.

Regards
NH



reddaly wrote:
>
> On Jul 28, 3:09 pm, johnjbarton <[email protected]> wrote:
>   
>> On Jul 28, 2:23 pm, reddaly <[email protected]> wrote:
>> ...
>>
>>     
>>>> Nevertheless I am interested in any incremental suggestions about
>>>> function names.
>>>>         
>>> My suggestion is to inspect the function object for an explicit, user-
>>> defined name.
>>>       
>> I've heard this suggestion before, I didn't understand it. If you
>> don't want anonymous functions, why don't you just name them? I mean
>> aren't function names are exactly equal to explicit user-defined
>> names?
>>     
>
> You suggest using a form like
>
> function myName() { ...}
>
> instead of
>
> var x = function () { ...}
>
> x.firebugName = "myName"
>
> However, this does not always work out.  Consider the case where a
> function returns another function.
>
> function compose (fn1, fn2) {
>  // returns a function that calls fn1 with the result of fn2
>  return function() { return fn1( fn2.apply(null, arguments)) }
> }
>
> Here, there is no sensible way to name the composed function (other
> than "composed function," which does not give any context about the
> functions it comprises).  Ideally, you would like to name it something
> recognizable.  e.g. compose(tagName, firstTag) would be named
> "tagName_firstTag."  The way to accomplish this best is to set a
> property on the function that firebug will inspect.
>
> Best regards,
> Red
>
>   
>> jjb
>>     
> >
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Firebug" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/firebug?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to