"Pretty" function expression names

Mike Wilson mikewse at hotmail.com
Sun May 10 03:10:19 PDT 2009


P T Withington wrote:
> Assuming we're allowed to speculate on futures here...
> 
> I was thinking about improving debug-ability by adding descriptive  
> names to function expressions thusly,
> 
>    var myFun = function "my description here" (...) { ... };
> 
> I.e., be able to use an arbitrary string as the "name" of a function  
> expression.

I'd like to ask everybody what you see as the primary use-
case for this function description? Examples (using ptw's
syntax and disregarding current grammar issues):

  function f() {
    function "local worker method in f"() {...}
  }

-or-

  name1: {
    subname2: {
      fn: function "name1.subname2.fn"() {...}
    }
  }

For debugability I often miss support for the latter case.
Could we possibly find cases when an automatically generated 
property could actually create this hierarchical name for us?

  name1: {
    subname2: {
      fn: function() {...}
    }
  }
  var f = name1.subname2.fn
  f.prettyname == "name1.subname2.fn"

This would only solve some use-cases, but those would be solved
with less keystrokes and effort, and without grammar changes.

All this may be way off from what is practical, but I just 
wanted to throw in that maybe the hierarchical naming scenario 
is one of the primary use-cases everybody is thinking of? 
Or maybe not?

Best regards
Mike Wilson



More information about the es-discuss mailing list