note 68005 deleted from language.exceptions by bjori
| From: | bjori@php.net | Date: | Fri, 28 Nov 2008 17:25:41 +0000 |
| Subject: | note 68005 deleted from language.exceptions by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-147078@lists.php.net to get a copy of this message | ||
Note Submitter: tatarynowicz at gmail dot com
----
Carlos Konstanski: You can't directly extract previous lexical environment in non-functional
languages.
What you probably _can_ do is to create a function that dumps the current lexical environment (to an
external file or to stdout) and then use it to recreate past states.
function log_lex ($vars, $functions) {
$f = fopen('lex_env.log', 'a');
fwrite($f, serialize(array($vars, $functions, get_defined_constants(), debug_backtrace()));
fclose($f);
}
log_lex (get_defined_vars(), get_defined_functions());
Writing the parser/browser for dumps is the difficult part. Then just sprinkle the code with
log_lex() and see how the program runs.
Sure, it works better in Lisp, but Lisp isn't supported on the webservers I work with, and
making PHP more like Lisp would probably make it as popular as Lisp is.