by ericbb · 14y ago · 0 comments
mtime: function () {
return reset {
var mtime = shift (succeed) {
this.withFile ({ |f|
var mtime = this.mtimeFor (f);
if (mtime < new Date () - 1000) {
return "too old";
}
return succeed (mtime);
});
};
sys.print (mtime);
return "young enough";
};
},
The succeed function is a first class, indefinite-extent function equivalent to: function (mtime) {
sys.print (mtime);
return "young enough";
}
It's the computation within the reset block that comes after the shift form is evaluated.Calling it after returning from the method would not raise an exception.
Edit: Keep blocks with 'this' inheritance (I had originally used a standard closure).
While I'm thinking about it... I wonder about the choice to overload/reuse the keyword 'return' in the blocks proposal. Any thought on using something else to emphasize the distinction in semantics?
Edit: Nevermind. That would break the Tennent Correspondence Principle wouldn't it? Bad idea.