Re: Namespaces, or getting function foo.bar() declarations to work



Richard Cornford wrote:

However, in all of these, the functions created are
anonymous. This may make no difference, but I don't
like it and it impacts debugging, when you're trying
to determine their name.

This assumption appears to be the crux of your issue, but
you have not explained or justified it. Most javascript
error reports output line numbers (at minimum) so I don't
see any need to have a name associated with the function
for debugging.

It's not an assumption, they really are anonymous. ...

That was not the assumption. The assumption was that using anonymous
functions would impact debugging. It is an assumption as anonymous
functions are common on non-trivial javascript and if their use really
was a problem when debugging that would have been noticed by now.

I said why it impacts debugging, if no one else is bothered by that is another matter. For all I know, people are tearing their hair off for the short supply of great javascript IDEs. I don't think it would hurt that a name could be determined for every function (if not their own, that of the variable they are assigned to, or that of the scope object).

function foo()
{
function bar()
{
debug('hello', 1, 'a')
}
}

And function debug would output something like

'10:04:55 [foo] hello, 1, a'

The 'hello' got into that output because you put it there, why not put
in the information that tells you what you need in the output, like
something that tells you the context of the debug call?

Only because it would have to be done every time. Given the dynamic nature of javascript, it's even possible that 'bar' is bound to other scope, so maybe something like

'10:04:55 [foo > bar] hello, 1, a'
'10:04:57 [dif > bar] hello, 1, a'

would be even more interesting. The next version of ECMAScript could surely define some more meta- functionality for functions, something that could be put to good use by IDEs.
--
am

laurus : rhodophyta : brezoneg : smalltalk : stargate
.



Relevant Pages

  • FAQ Topic - How do I get my browser to report javascript errors? (2009-07-23)
    ... There are debugging tools for many browsers. ... but can be attached to any browser running on Windows. ... Microsoft Script Editor. ... JavaScript Console: click the ` Page ` menu icon and select ...
    (comp.lang.javascript)
  • FAQ Topic - How do I get my browser to report javascript errors? (2009-09-19)
    ... There are debugging tools for many browsers. ... but can be attached to any browser running on Windows. ... JavaScript Console: click the ` Page ` menu icon and select ...
    (comp.lang.javascript)
  • Re: Help with Javascript
    ... You can enable JavaScript debugging on your local test machine. ... The progress bar is a gif animation and for some reason it the ... I have decided to put a wait function that will pause ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: .NET 2005
    ... JavaScript code can be debugged, but not in the same way as ASP.Net, because ... For debugging JavaScript, you set up Internet ... Uncheck the "Disable Script Debugging (Internet Explorer)" ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: WMP v.11 - Audio but no Video
    ... permit "javascript debugging" and you will immediately see the errors. ... To turn on debugging in IE browser, go to the menu ... player displays at the requested width x height. ... available to the DOM until the page load is complete, ...
    (microsoft.public.windowsmedia.player.web)