Skip to content

Avoid using "eval" in a neat way

7 messages · Hai Qian, Ista Zahn, Duncan Murdoch +2 more

#
This has been discussed extensively, on this list as well as
elsewhere. I suggest doing a web search, read up on the issue, and
post back here only if you have specific questions that are not
answered already.

Best,
Ista
On Sat, Feb 1, 2014 at 11:40 AM, Hai Qian <hqian at gopivotal.com> wrote:
#
On 14-02-01 11:40 AM, Hai Qian wrote:
You're asking how to parse some text and evaluate it without using eval. 
Sounds impossible to me.

Duncan Murdoch
#
You have set up your criteria for success to be that your user has full freedom to specify code in strings to evaluate. Then you ask how to achieve this goal without evaluating that code. Are you thinking objectively at all about your question?

The advice to not use eval has a number of justifications that you should be able to find yourself online (unnecessary obfuscation and program security are two). Implementing an interpreter is not where this advice applies.

At the core of this problem, as long as you accept that your user is working within the R interpreter then they can provide your code with functions that access data on their own. You don't need to assume so much responsibility as your question assumes you have to.

"Doctor, my head hurts!"
"Then stop banging it against the wall."
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
On February 1, 2014 8:40:47 AM PST, Hai Qian <hqian at gopivotal.com> wrote: