I just came across this post: Java isn't just Python without the cool language features - Java platform as such does not miss cool scripting features. While the examples suggested are Jython Groovy and JRuby, I'd like to point out JavaScript can be added to the list as well - in particular because JDK 6 includes Rhino based JavaScript engine and JavaScript does support these:
JavaScript function arity is not fixed. A function can always get all arguments by arguments object. Also, function can check for undefined values.
function mul(x, y) {
// if 'y' is passed assume default value of '3'
if (y == undefined) y = 3;
return x * y;
}
Nested functions are supported -- "inner" function can be returned and stored. Inner functions have the "outer" function's local scope as "parent" scope and therefore can access locals of the outer function. If you are looking for Smalltalk-like block closures with special "return" instruction to return from enclosing function, then you have to simulate that by exceptions.