http://code.google.com/p/ejacs/
EmacsLispで書かれたJavaScriptインタプリタ。そういえば、去年にこっちでそんなことをやっているという記事を見た記憶が。
READMEを読むと、
Ejacs is a reasonably complete interpreter for the Ecma-262 specification
written entirely in Emacs-Lisp. It runs on GNU Emacs version 22 and higher.
ECMA完全準拠らしいですよ。さらに読んでいくと、
Ejacs provides a minimal interactive console for evaluating JavaScript
expressions and statements on the fly. The console also comes with a
built-in "load" command for loading and evaluating JavaScript files.
JavaScriptでEmacsを拡張できる時代が近づいてきたのかもしれません。さすがにそれはまだのようですが↓
Ejacs does not yet provide any integration with Emacs, so in its current
form it cannot be used to create customizations for Emacs.
より詳しくは作者のブログを見るといいかも↓
Ejacs: a JavaScript interpreter for Emacs
ダウンロードしたファイル群をロードパスの通った場所に置いて、
(autoload 'js-console "js-console" nil t)
M-x js-console
↑を実行すると、
Welcome to the EmacScript Console.
Semicolon (`;') on its own line cancels partial input.
js> 1
1
js> function test () { print("hello, world"); }
js> test();
hello, world
js>
クロージャも、
js> function Counter () {
var cnt = 0;
return f;
function f () {
return cnt++;
}
}
js> var cnt = 0;
js> var counter = Counter();
js> print(counter());
0
js> print(counter());
1
js> print(counter());
2
js> print(counter());
3
js>
タイトルがEjacsじゃなくてEjaxになってたので、修正しました。