Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 1
    \$\begingroup\$ @dan1111 Why ? It doesn't access any file. I was just pointing how to launch the program to people not used to node.js. It doesn't read the file. \$\endgroup\$ Commented Apr 18, 2013 at 6:49
  • 1
    \$\begingroup\$ All of the Javascript solutions take advantage of the fact that you can access your own source code in JS. That may not be technically "accessing the file of its own source code", but it accomplishes the exact same thing. I suppose your answer is legal, though, as the question didn't specifically forbid this. \$\endgroup\$ Commented Apr 19, 2013 at 9:32
  • \$\begingroup\$ Well, you access the source of a function (only the body to be precise) which is part of the program. That's like using mixin() in D. But I don't think the two other JS answers, including one from me, really qualify as "programs", though. \$\endgroup\$ Commented Apr 19, 2013 at 9:36
  • \$\begingroup\$ @dystroy actually mixin in D is more like using eval than reading source \$\endgroup\$ Commented Apr 19, 2013 at 9:51
  • \$\begingroup\$ @ratchetfreak yes, you're right. But I think your program uses a kind of toString of the enum value, right ? And any code using eval/mixin is about the same trick than using the source of the function. \$\endgroup\$ Commented Apr 19, 2013 at 9:54