Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed101.telia.com!starscream.dk.telia.net!news.tele.dk!feed118.news.tele.dk!not-for-mail Newsgroups: comp.lang.javascript Subject: Re: Get value of named object References: <39ekeff9.fsf@gmail.com> From: Lasse Reichstein Nielsen Date: Sun, 23 Oct 2011 11:57:24 +0200 Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Rational FORTRAN, windows-nt) Cancel-Lock: sha1:bhCfX7aL5ExQIR/lpUFxul0Z9rw= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 44 Organization: TDC Totalloesninger NNTP-Posting-Host: 87.57.52.80 X-Trace: 1319363845 dtext01.news.tele.dk 293 87.57.52.80:33837 X-Complaints-To: abuse@post.tele.dk Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:7635 Swifty writes: > On Sun, 23 Oct 2011 02:10:18 +0200, Lasse Reichstein Nielsen > wrote: > >>I still think it's a bad idea. > > Is it bad as used at http://swiftys.org.uk/jsvars.html ? That page is so simple and, probably, only really for your own usage. Performance is irrelevant. Complexity is minimal. You control all strings that are being passed to eval. By all means, use eval. The only problem is that someone might see it an think it's an acceptable method to use in real production code, where complexity is higher, you might not know which strings will end up there, and performance might matter. > It delivers the correct answers. It does. And it's simple to read. > This reminds me of my mathematics teacher, Mr Olver. If I got an > answer right, but through faulty reasoning, he would say "Right answer > for the wrong reason, Swift. No points". He had a point. Now imagine that all mathematics answers were posted on the web, and new mathamtics students would find a random solution and learn their methods from that. In that case, not marking bad solutions as bad is actually harmfull. That's where we've been, and still is, with javascript coding on the web. It's not that "eval" can't be useful, or even essential, in a few select cases *if you know what you're doing*. It's just that for each of those cases, there are thousands of "programmers" that add "eval" calls that are, at best, unnecessary, and that all have safer, faster and simpler solutions without eval. /L -- Lasse Reichstein Holst Nielsen 'Javascript frameworks is a disruptive technology'