4 ms·
But this could be solved with escape analysis. Rarely do such let locals shadow outer locals, and as such don't need to be restored.
by rurban 8y ago
But this could be solved with escape analysis. Rarely do such let locals shadow outer locals, and as such don't need to be restored.
- dan-robertson 8y agoYou can’t know whether you are shadowing an outer variable. With dynamic scope: (defun get-x () x) (defun foo (let ((x 7)) (get-x))) (foo) ;; => 7 (not shadowing x) (let ((x 4)) (foo)) ;; => 7 (is shadowing x) (setq old-get-x #'get-x) (defun get-x () (let ((x 10)) (funcall old-get-x))) (foo) ;; => 10
- rurban 8y agoOuch, you are right. So the only strategy would be to switch to lexical compilation blockwise, while fixing the remaining dynamic extent vars.
- pzone 8y agoWhich is more or less the strategy in the Emacs codebase - the intention is to incrementally port to lexical binding on a per-file basis. (This is seen through the annotation -- lexical-binding:t -- at the top of many .el files.)
- kazinator 8y agoEmacs Lisp has supported lexical scope in its byte code compiler as an option for eons, and is starting to make more use of that. No reason why a brand new JIT couldn't follow suit.