Loading ...
Sorry, an error occurred while loading the content.

alternatives to eval for user-supplied functions

Expand Messages
  • firstbakingbook
    I need to support user-supplied math functions. Are there any good alternatives to using eval, or, more likely, the Function constructor? I could write js code
    Message 1 of 1 , Jan 29, 2013
    • 0 Attachment
      I need to support user-supplied math functions. Are there any good alternatives to using eval, or, more likely, the Function constructor?

      I could write js code to evaluate js expression parse trees, though I suspect the performance wouldn't be acceptable.

      It looks like ADsafe is a bit like this (running 3rd party code safely), but I don't really understand ADsafe usage. Are you expected to run jslint on a server, before serving the js to the browser? If so, that doesn't help. I could run jslint in the browser, but then wouldn't I still need to eval the code if it passed? In that case I can use something simpler and much more restrictive than jslint.
    Your message has been successfully submitted and would be delivered to recipients shortly.