News for hackers. Stuff that matters.
Re:Sublime Text 2 Beta released with Auto-complete and Impro... by est on Thursday January 12, 2012 @02:54AM (#3455454)
> Jump the the function/method definition

for scripting languages, define a function as concatenated string in eval(), how could you find the function definition, without actually run the script for once?

Even if you run the script once, what if there is a delete_file() function you accidently called?

So do we need to implement a sandboxed VM in order to find definition, theoretical perfectly speaking?

Re:Sublime Text 2 Beta released with Auto-complete and Impro... by johns on Thursday January 12, 2012 @03:04AM (#3455485)
Or just don't offer click navigation on functions defined in eval(). Acceptable trade off.
Re:Sublime Text 2 Beta released with Auto-complete and Impro... by tsandall on Thursday January 12, 2012 @03:04AM (#3455481)
sure, theoretically speaking you can't figure out everything until runtime, however even with 'scripting language' code you can still get quite far with basic static analysis.
Re:Sublime Text 2 Beta released with Auto-complete and Impro... by rorrr on Thursday January 12, 2012 @03:05AM (#3455486)
That's such an edge case. I've never seen anybody defining functions in evals, especially as concatenated strings.
Re:Sublime Text 2 Beta released with Auto-complete and Impro... by TylerE on Thursday January 12, 2012 @01:06PM (#3457315)
I've done it.

Use case involves a class wrapping python's xml-rpc stuff to talk to Drupal.

Drupal's xml-rpc interface is not the most pleasant thing to work with, as you have to pass in a session id and auth token on every request, and then all the "actual" parameters go in as an array.

My wrapper class would query the remote interface for available methods, and then dynamically generate, via eval, a function object that used a closure to store the sess/auth tokens, and that took a variable number of arguments to pass as the 3rd array argument to the function. The eval'd function object was then bound as a method to the connection object.

It also did a bit more magic, such as on error logging the arguments to a file. ALl in all it made writing web-service clients a lot more pleasant.

Re:Sublime Text 2 Beta released with Auto-complete and Impro... by agento on Thursday January 12, 2012 @03:40AM (#3455566)
Maybe you should take a look at the Rails sourcecode.
Re:Sublime Text 2 Beta released with Auto-complete and Impro... by FooBarWidget on Thursday January 12, 2012 @08:35AM (#3456234)
Rails only does that to optimize certain function calls. eval() is used as a method to compile/inline certain functions. Most code in Rails does not use eval.
Re:Sublime Text 2 Beta released with Auto-complete and Impro... by drothlis on Friday January 13, 2012 @02:03AM (#3459514)
https://github.com/rails/rails/blob/2-3-stable/actionpack/li...

Try getting your editor to find that definition of method "accept_language" or "cache_control". :-)