from.. 2010-04-03 13:50 采纳率: 50%
浏览 388

究竟为什么伊瓦尔是邪恶的?

I know that Lisp and Scheme programmers usually say that eval should be avoided unless strictly necessary. I’ve seen the same recommendation for several programming languages, but I’ve not yet seen a list of clear arguments against the use of eval. Where can I find an account of the potential problems of using eval?

For example, I know the problems of GOTO in procedural programming (makes programs unreadable and hard to maintain, makes security problems hard to find, etc), but I’ve never seen the arguments against eval.

Interestingly, the same arguments against GOTO should be valid against continuations, but I see that Schemers, for example, won’t say that continuations are "evil" -- you should just be careful when using them. They’re much more likely to frown upon code using eval than upon code using continuations (as far as I can see -- I could be wrong).

转载于:https://stackoverflow.com/questions/2571401/why-exactly-is-eval-evil

  • 写回答

12条回答 默认 最新

  • 衫裤跑路 2010-04-03 13:55
    关注

    Eval is fine, as long as you know EXACTLY what is going into it. Any user input going into it MUST be checked and validated and everything. If you don't know how to be 100% sure, then don't do it.

    Basically, a user can type in any code for the language in question, and it will execute. You can imagine for yourself how much damage he can do.

    评论

报告相同问题?