Did nobody see my email? There is already a mechanism in the works for exposing this kind of metadata:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import.meta https://github.com/tc39/proposal-import-meta/blob/master/README.md On Fri, Aug 24, 2018, 07:56 Aaron Gray <aaronngray.li...@gmail.com> wrote: > On Fri, 24 Aug 2018 at 04:56, J Decker <d3c...@gmail.com> wrote: > >> On Thu, Aug 23, 2018 at 5:26 PM Aaron Gray <aaronngray.li...@gmail.com> >> wrote: >> >>> I am debugging existing code that I have modularized, and am class'izing >>> that has unittests and it just would have been very useful to have this >>> facility. >>> >> In a browser, console.log is usually associated with the file and line >> number anyway; which includes using devtools with node.... but it would be >> handy for logging. with V8 there is console.trace; which spits out the >> stack trace too... before I discovered that I did a logging function >> like... >> >> (from >> https://stackoverflow.com/questions/591857/how-can-i-get-a-javascript-stack-trace-when-i-throw-an-exception >> ) >> function stackTrace() { var err = new Error(); return err.stack; } // >> parse stack to get frame-1 online >> >> // or maybe just frame-1... >> function stackTrace() { var err = new Error(); return err.stack.split( >> "\n" )[1]; } >> >> --- >> function stacktrace() { >> function st2(f) { >> return !f ? [] : >> st2(f.caller).concat([f.toString().split('(')[0].substring(9) + >> '(' + f.arguments.join(',') + ')']); >> } >> return st2(arguments.callee.caller); >> } >> >> EDIT 2 (2017) : >> >> In all modern browsers you can simply call: console.trace(); (MDN >> Reference) >> > > Yes slightly long winded to say the least :) > > >> --- >> >> Although I do still miss just being able to get __FILE__ and __LINE__ >> > > Yeah it should be easy to have such stuff compiled by JIT > > Aaron > >> -Gus >>>> >>>> ---- On Thu, 23 Aug 2018 17:56:43 -0500 *Aaron Gray >>>> <aaronngray.li...@gmail.com <aaronngray.li...@gmail.com>>* wrote ---- >>>> >>>> I wondering what people think about the idea of proposing being able to >>>> get the line number and filename of executing code in the code ? Maybe with >>>> something simular to C preprocessors __line_number__ and __filename__. Or >>>> as subobjects of global ? >>>> >>>> -- >>>> Aaron Gray >>>> >>>> Independent Open Source Software Engineer, Computer Language >>>> Researcher, Information Theorist, and amateur computer scientist. >>>> _______________________________________________ >>>> es-discuss mailing list >>>> es-discuss@mozilla.org >>>> https://mail.mozilla.org/listinfo/es-discuss >>>> >>>> >>>> >>>> >>> >>> -- >>> Aaron Gray >>> >>> Independent Open Source Software Engineer, Computer Language Researcher, >>> Information Theorist, and amateur computer scientist. >>> _______________________________________________ >>> es-discuss mailing list >>> es-discuss@mozilla.org >>> https://mail.mozilla.org/listinfo/es-discuss >>> >> > > -- > Aaron Gray > > Independent Open Source Software Engineer, Computer Language Researcher, > Information Theorist, and amateur computer scientist. > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss