Firefox 2.0 beta 1 ãåºã¾ããã^^
ãã£ãããæ°æ©è½ã®ã²ã¨ã¤ãJavaScript 1.7 ã® yield ã使ã£ã¦ã¿ã¾ããã
ã¾ã yield ã®åä½ã試ãã¦ã¿ãã
var i = 1; var g = (function() {while(1) {yield i; i++}})(); alert(i); // 1 g.next(i); g.next(i); alert(i); // 2
ããã§åãã£ããã¨ã
ãªãã¨ã
yield ã¯é¢æ°ãéä¸ã§çµäºããã¦ãããããï¼
å®ã¯ã
ãã¾ã¾ã§ãä½åº¦ãé¢æ°ãéä¸ã§çµäºã§ããã°ãªã¼ã¨æã£ã¦ããã
JavaScript 以å¤ã®ã»ã¨ãã©ã®è¨èªã§ãããå¯è½ã§ãããã便å©ã ããã§ããã
ããã¨ã¯ãªã«ããããã¨ã¯ã¹ã¬ããã§ããã
ã¹ã¬ãã㯠CPU ã¬ãã«ã§ç´°ãã¼ãå¦çãæ¢ãã¦ãããããªå¦çã®æµããåæã«å®è¡ããã¦ãããããªãã®ã ã
yield ã使ã£ãã JavaScript ã§ã¹ã¬ããã®ãããªãã®ãä½ããã®ã§ã¯ï¼
ã¨ãã仮説ã
å®éã«ä½ã£ã¦ã¿ãã
â Firefox 2.0 beta 1 ãªã©(JavaScript 1.7 以ä¸ãåãç°å¢)ã§è¦ã¦ãã ããã
http://sample.ecmascript.jp/js17.html
ããããï¼
åè§ãç®±ãããããåã£ã¦ããã®ãè¦ããã ãããã
ã¹ã¬ããé¨åã®ã½ã¼ã¹ã¯ãããªæã
function() { var $thread; while(true) { while(this.topCache < 200) { yield $thread; this.topCache += 2; this.style.top = this.topCache + 'px'; this.style.opacity = this.opacityCache += 0.01; } while(this.leftCache < 200) { yield $thread; this.leftCache += 2; this.style.left = this.leftCache + 'px'; this.style.opacity = this.opacityCache -= 0.01; } while(this.topCache > 100) { yield $thread; this.topCache -= 2; this.style.top = this.topCache + 'px'; this.style.opacity = this.opacityCache += 0.01; } while(this.leftCache > 100) { yield $thread; this.leftCache -= 2; this.style.left = this.leftCache + 'px' this.style.opacity = this.opacityCache -= 0.01; } } }
ãã¨ã¯ setInterval ã§åãã ãã
setInterval(function() {g.next()}, 10);
ãããä»ã¾ã§ã® JavaScript ã§ãã£ãããã©ãã ãããã©ãããã ãããã
ãã®ã½ã¼ã¹ã§ã¯ã¾ã ã¾ã åããä¼ãããªããããããªããã©ã
Java ãªã©ã§æ¸ãããã¹ã¬ããåæã®ããã°ã©ã ã JavaScript ã«ç§»æ¤ã§ãããããããªããï¼Orto ã使ããªãã¦ãwï¼
ããã ããããªãããã£ã¨ãã£ã¨ãã£ã¨ããããªãã¨ãã§ããï¼
ãã¯ã¼ã夢ãã²ããããã ã(+â+)ããã¼ãã©ãããã¨ã¼
ä½ã§ãã§ããï¼We can fly!
ãï¼ãIE ã£ã¦ãªãã ãï¼