Is there ever a good reason to use eval()?

后端 未结 10 1079
清歌不尽
清歌不尽 2020-12-03 20:51

It seems to me that eval() is treated with the same disdain that goto is. And by eval, I mean a function for executing a string as code, as seen in

10条回答
  •  死守一世寂寞
    2020-12-03 21:21

    Yes - when there is no other way to accomplish the given task with a reasonable level of clarity and within a reasonable number of lines of code.

    This eliminates 99% of cases where eval is used, across the board in all languages and contexts.

提交回复
热议问题