> var myobj = require( the-file );
> eval( 'myobjs.' + file-name = myobj;');

How has no one commented on the fact that you're doing
numeric arithmetic on a bunch of strings? All this is going to do is give
you a parse error, and when you fix that you're just doing require(NaN).

With all due respect to your 25 years of software I do think you need to
take a step back and start with the basics here until you build up a good
foundation. I don't think you're in the position right now to fully reason
whether eval() is evil or not. You can trust Rick, he is a JS oracle.

On Wed, Dec 12, 2012 at 9:43 PM, Rick Waldron <[email protected]>wrote:

>
> On Wednesday, December 12, 2012 at 8:09 PM, Jorge Chamorro wrote:
>
> On 13/12/2012, at 01:47, Rick Waldron wrote:
>
>
> On Wed, Dec 12, 2012 at 7:20 PM, Jorge Chamorro <[email protected]>
> wrote:
> On 12/12/2012, at 18:37, Rick Waldron wrote:
>
>
> On Wed, Dec 12, 2012 at 2:17 AM, Isaac Schlueter <[email protected]> wrote:
> On Tue, Dec 11, 2012 at 7:18 PM, spqr <[email protected]> wrote:
>
> maybe my question should have been "why does JavaScript have eval()?" ;-)
>
>
> I think a lot of people have wondered the same thing.
>
> Yes, it has its uses, but at this point, I don't know of any that
> aren't better served using some other mechanism. eval() has weird
> optimization-destroying semantics that cannot ever be changed, due to
> the fact that JavaScript must be backwards compatible forever.
>
>
> Runtime code generation? new Function( thecode ) works just as well, I
> guess
>
>
> ...sometimes:
>
> (function (p) {
>
> eval("(function(){console.log(p)})")();
>
> try {
> Function("console.log(p)")();
> }
> catch (e) {
> console.log("FAIL -> "+ e.message);
> }
>
> })("OK");
>
> OK
> FAIL -> Can't find variable: p
>
>
> Of course not, but that's not what I was talking about, is it? I
> definitely said "Runtime code generation", by which I meant "the entire
> program" is first generated, by some means, into a string, which is then
> eval'ed. See also: Traceur, CoffeeScript (anything the compiles something
> else into JavaScript at runtime)
>
>
>
> (Sorry I hit send too soon)
>
> Well put, simple as that, I completely agree.
>
> What eval() is: a call right to the compiler as in compile(program), which
> is -no matter what they say- a very nice -power- feature to have.
>
> And a footgun? Perhaps *sometimes*, yes, so? Beware and don't be fool!
>
> Yet the fools are foolish and there's little to do about that, neither
> eval() *nor*the*threads* are evil, nor the culprits.
>
>
> I agree with every single word and all of the sentiments they imply.
>
> Rick
>
> --
> Jorge.
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" 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/nodejs?hl=en?hl=en
>
>
>  --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" 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/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" 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/nodejs?hl=en?hl=en

Reply via email to