Hacker News new | past | comments | ask | show | jobs | submit login

Alternate formulation with hypothetical shift/reset (delimited continuation support) and blocks that return the same way functions do:

    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).

Thanks for the links. It's neat to see such things being considered. My feeling is that such complicated language devices are out of place in JavaScript but it was fun to run the experiment.

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.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact