I'm admittedly unsure about why var def was introduced, but I don't see why it has to exist.
For most intents and purposes, a var def is exactly the same as assigning a do block to a variable. It does not seem to do anything more or less than that.
For example, these are pretty much identical:
var def foo x, y = 12, *z
console.log 'called'
var foo1 = do |x, y = 12, *z| console.log 'called'
Compiled output:
function foo(x,y){
var $0 = arguments, j = $0.length;
if(j < 2) y = 12;
var z = new Array(j>2 ? j-2 : 0);
while(j>2) z[--j - 2] = $0[j];
return console.log('called');
};
var foo1 = function(x,y) {
var $0 = arguments, j = $0.length;
if(j < 2) y = 12;
var z = new Array(j>2 ? j-2 : 0);
while(j>2) z[--j - 2] = $0[j];
return console.log('called');
};
Compared to def, var def methods can be assigned and passed around. So can do blocks that are assigned to variables, and so can normal methods as of 1.4 where they can be referenced as self:foo. So var def seems to be redundant.
I'm admittedly unsure about why
var def
was introduced, but I don't see why it has to exist.For most intents and purposes, a
var def
is exactly the same as assigning ado
block to a variable. It does not seem to do anything more or less than that.For example, these are pretty much identical:
Compiled output:
Compared to
def
,var def
methods can be assigned and passed around. So cando
blocks that are assigned to variables, and so can normal methods as of 1.4 where they can be referenced asself:foo
. Sovar def
seems to be redundant.