JavaScript 1.7風

もう寝ます…

function yield(nextval) {
  var generator = {};

  generator.next = function() {
    return (typeof(nextval) == "function") ? nextval() : nextval;
  }

  return generator;
}
  
function make_fib() {
  var a = 1;
  var b = 1;

  return yield(function() {
    var t = a;
    a = b;
    b = t + b;
    return t;
  });
}

var fib = make_fib();

for(var i=0; i<10; i++)
  print(fib.next());