[JSR308] annotations on expressions and literal values
Michael Ernst
mernst at csail.mit.edu
Wed Jan 31 14:51:09 EST 2007
> Object result = engine.eval(
> "fib(num);" +
> "function fib(n) {" +
> " if(n <= 1) return n; " +
> " return fib(n-1) + fib(n-2); " +
> "};" @Script("JavaScript"),
> bindings);
Annotations on types already permit this this using a cast:
Object result = engine.eval(
(@Script("JavaScript") String) // <--- this is the cast
"fib(num);" +
"function fib(n) {" +
" if(n <= 1) return n; " +
" return fib(n-1) + fib(n-2); " +
"};",
bindings);
One advantage of the cast syntax is that it does not introduce new syntax.
-Michael Ernst
mernst at csail.mit.edu
More information about the JSR308
mailing list