Jeene is a new open source project by Karl Krukow, which aims to create a partial evaluator for JavaScript.

A partial evaluator (or program specializer) is a program which takes two inputs: another program and an environment mapping variables to values; it outputs a specialized (i.e., more efficient) version of the input program with respect to the environment. One can think of a partial evaluator as a mix between an interpreter and a compiler: it interprets the static parts of the program and emits code for the dynamic parts.

JAVASCRIPT:

  1.  
  2. // This code actually works ;-)
  3. Function.prototype.specialize = net.higherorder.jeene.Jeene.make();
  4.  
  5. var mk_tag = function(tag,clz,cont) {
  6.   return “<”+tag+” class=’”+clz+“‘>”+cont+“”;
  7. };
  8.  
  9. var mk_div_green = mk_tag.specialize({tag:‘div’, clz: ‘green’});
  10.  
  11. mk_div_green(“Pratt rocks!”);
  12. //result: <div class=’green’>Pratt rocks!</div>
  13.  
  14. mk_div_green.toSource ? mk_div_green.toSource() : mk_div_green.toString();
  15. //result:
  16. //(function (cont) {return ("<div class=’green’>" + cont) + "</div>";})
  17.  

This last line, shows that the output function is much more efficient than what is created by general JavaScript curriers which have been seen before. These functions merely wait evaluating the function until all parameters are supplied; instead, a partial evaluator will create specialized function taking advantage of the information given.

Source: Ajaxian » Front Page
Original Article: http://feeds.feedburner.com/~r/ajaxian/~3/394079463/jeene-automatic-partial-evaluation-for-javascript-in-javascript

Comments are closed.



Site Navigation

Warning: MagpieRSS: Failed to parse RSS file. (junk after document element at line 8, column 9) in /home/tipsclub/public_html/ajaxgirl/wp-content/plugins/wp-autoblog/rss_fetch.inc on line 237

Warning: gmmktime() expects parameter 3 to be long, string given in /home/tipsclub/public_html/ajaxgirl/wp-content/plugins/wp-autoblog/rss_utils.inc on line 35

Warning: gmmktime() expects parameter 3 to be long, string given in /home/tipsclub/public_html/ajaxgirl/wp-content/plugins/wp-autoblog/rss_utils.inc on line 35

Warning: gmmktime() expects parameter 3 to be long, string given in /home/tipsclub/public_html/ajaxgirl/wp-content/plugins/wp-autoblog/rss_utils.inc on line 35

Warning: gmmktime() expects parameter 3 to be long, string given in /home/tipsclub/public_html/ajaxgirl/wp-content/plugins/wp-autoblog/rss_utils.inc on line 35

Warning: gmmktime() expects parameter 3 to be long, string given in /home/tipsclub/public_html/ajaxgirl/wp-content/plugins/wp-autoblog/rss_utils.inc on line 35

Warning: gmmktime() expects parameter 3 to be long, string given in /home/tipsclub/public_html/ajaxgirl/wp-content/plugins/wp-autoblog/rss_utils.inc on line 35

Warning: gmmktime() expects parameter 3 to be long, string given in /home/tipsclub/public_html/ajaxgirl/wp-content/plugins/wp-autoblog/rss_utils.inc on line 35

Warning: gmmktime() expects parameter 3 to be long, string given in /home/tipsclub/public_html/ajaxgirl/wp-content/plugins/wp-autoblog/rss_utils.inc on line 35

Warning: gmmktime() expects parameter 3 to be long, string given in /home/tipsclub/public_html/ajaxgirl/wp-content/plugins/wp-autoblog/rss_utils.inc on line 35

Warning: gmmktime() expects parameter 3 to be long, string given in /home/tipsclub/public_html/ajaxgirl/wp-content/plugins/wp-autoblog/rss_utils.inc on line 35