Zedãä»åº¦ã¯PGã®ãArc Challengeãã«ææ¦ç¶ãLuaã«ããç¶ç¶ã¹ã¿ã¤ã«ã®ãã¤ã¯ããã¬ã¼ã ã¯ã¼ã¯ã
http://sheddingbikes.com/posts/1289384533.html
話é¡ã®çµ¶ããªãZedãã¾ãå½¼ã®å¼·åãªãã¼ã½ããªãã£ã«é¢ãã話ã«ãªã£ã¦ãã¾ããããã®åã«ããã¯æ¬å½ã®Zedãä½ã£ã¦ãããã£ã©ã§ãã£ã¦ãããã«ã¼ã¨ãã¦ã®ç価ã¯å½¼ã®ããã¸ã§ã¯ãã«ãã£ã¦è©ä¾¡ãããã¹ãã ã¨è¨ã£ã¦ããããããã®æ°ã¶æã«Pythonã®å ¥éæ¸ãæ¸ãä¸ããMongrel2ããªãªã¼ã¹ããããã«Luaã§co-routineããããã¤ã¯ããã¬ã¼ã ã¯ã¼ã¯ãæ§ç¯ãããªã©ãé¢ç½ãå®é¨ãè¡ãªã£ã¦ãããåãåºåã ã
ãã¦ããã©ãã®å§ã¾ããPGã®è¨èªArcã¯ãããã°ã©ã ãæçåããã®ãç®çã¨ããè¨èªãã¨ãããã¨ã«ãªã£ã¦ããããã®æå³ãæãã«ããããã«ãArc Challengeããªããã®ãæå±ããã次ã®ã¦ã§ãã¢ããªãä½è¡ã§æ¸ãããï¼
- ã¦ã¼ã¶ã«ã¤ã³ããããå°ãã
- ä¸éãã¼ã¸ãè¦ããªã³ã¯ã表示
- ãã®ãªã³ã¯ã辿ãã¨å ã®ã¤ã³ãããã表示ããã
- URLã«ã¤ã³ããããå ¥ããã®ã¯åå
Arcã®åçã¯
ããã«å¯¾ãã¦Zedæ°ãï¼ ãããããä½ãã£ã¦ãã ãå ¨ç¶ããããªãã
(defop said req
(aform [onlink "click here" (pr "you said: " (arg _ "foo"))]
(input "foo")
(submit)))
ãæåã«ãããè¦ãã¨ããWTFï¼ã(ãªãããããã)ã¨æã£ããLispã¯ãã£ããã¨ããããæå³ãããããªãã
ãLispã®åé¡ã¯ãåã®ã³ã¼ããç解ã§ããã®ã¯åã¨ç©ºé£ã¶ã¹ãã²ããã£ã¼ã¢ã³ã¹ã¿ã¼ã ãã«ãªã£ã¦ãã¾ãã¾ã§ã®metaprogramãåãå ¥ãã¦ãã¾ããã¨ã ã
ArcWTF Challenge
ãªã®ã§ããArcWTF Challengeããæå±ãã
- Arc Challengeã®åçã(ä»»æã®è¨èªã»ãã¬ã¼ã ã¯ã¼ã¯ã§)æ¸ã
- ã¦ã§ãã¢ããªã±ã¼ã·ã§ã³ãç«ã¡ä¸ãã
- ã¨ãã£ã¿ã¼ã§åã®ã³ã¼ãã¨Arcã®ã並ã¹ã¦è¡¨ç¤ºãã
- ããã°ã©ã ãæ¸ããªã人ã«ãã©ã¦ã¶ã§ã¢ããªã使ããã
- ä½ã説æããªãã§ãArcã³ã¼ããè¦ãã¦ããããã¯ä½ãããã®ãã¨å°ãã
ããã§ãã®äººã¯WTFï¼ã¨è¨ãã ãã
- 次ã¯ãã®äººã«åã®ã³ã¼ããè¦ãã
ããä½ãã£ã¦ããã®ããããã°ç¬¬ä¸ã©ã¦ã³ãã¯åã¡ã
- ã©ã£ã¡ã®ãã¡ã¤ã«ãã¦ã§ãã¢ããªãåããã¦ããã®ãã¨å°ããã
ããåã®ãé¸ã°ãããæçµã©ã¦ã³ããåã¡ã
ããã°ã©ãã§ãªã人ã«ã³ã¼ããè¦ã¦ã¦ãåºå¥ã¯ã¤ããªãã ããããZedã®è¨ããããã¨ã¯ãããã究極ã®ç°¡æ½ããããèªã¿å®ããæ±ããã£ã¦ãã¨ã§ããã
Luaã«ããZedã®ãArc Challengeãã®åçã¯
詳ããã¯å è¨äºãåç §ï¼ http://sheddingbikes.com/posts/1289384533.html
require 'tir/engine'local prompt_page = Tir.view("index.html")
local link_page = Tir.view("link.html")
local reply_page = Tir.view("response.html")local prompt_form = Tir.form {'msg'}
local function arc(web, req)
local params = {}repeat
params = web:prompt(prompt_page {form = params})
until prompt_form:valid(params)web:page(link_page {})
web:click()web:page(reply_page {form=params})
endTir.start {route = '/arc', main=arc}
Zedã®ã³ã¡ã³ãï¼
ã¡ãããããTirã¯Arcã«ããè² ãã ã23è¡ãã®èªãããç解ã§ããããããã«ãã©ã¼ããããããå®å
¨ãªãã¼ã¿ã¹ãã¢ãå¿
è¦ã¨ããªãLuaã³ã¼ãã ãããããããå
¥åå¤ã確èªãã¨ã©ã¼ã¡ãã»ã¼ã¸ã表示ãããããã«ããã³ãã¬ã¼ãã¯èª°ã§ãããããæ®éã®HTMLã ã
ä¸ã¤ã®é¢æ°ã®ä¸ã§è¤æ°ã®HTTPãã©ã³ãºã¢ã¯ã·ã§ã³ãçºçããcontinutationã¹ã¿ã¤ã«ã使ã£ã¦ããã¨ããã¯Arcã¨åãããã ãã¡ãªã¿ã«ãPerlã«ãããã®ææ³ã¯ä»¥ååãä¸ãããã¨ãããï¼ http://d.hatena.ne.jp/karasuyamatengu/20090908/1252441668
ãã®Tirã¨ããã®ã¯ãMongrel2ã®éçºã«åãã¦Zedãä½ã£ãLuaã«ãããã¤ã¯ããã¬ã¼ã ã¯ã¼ã¯ã ãPythonã®æ¬ãæ¸ãçµãã¦ãPythonã«é£½ãã¦ãã¾ã£ãZedã¯Luaã«ããã£ã¦ããããã ãã¾ã èµ°ããã¦ããªãã®ã§ããç解ããªãããè¦ç¹ã訳ãã¦ã¿ãã¨ï¼
ãã¤ã³ã¿ã¼ãã§ã¼ã¹ãã«ã¯ããã»ã¹ã¨é¢æ°ãä¸ãããã
OSããã»ã¹ãªã®ãè¨èªã®ã©ã¤ãã¦ã¨ã¤ãããã»ã¹ãªã®ãã¯ä¸æ
ãã³ãã©ã¯ãæ®éã®ãã¸ãã¯ãã§æ¸ãã
ä¸è¨ã®ç¶ç¶ã¹ã¿ã¤ã«ã®ãã¨ãè¨ã£ã¦ããã®ã ã¨æã
HTTPãªã¯ã¨ã¹ãæ¯ã«ãã³ãã©ãæ¸ããªãã§ãä¸ã¤ã®é¢æ°ã§æ®éã®æµãã§æ¸ããã¨ãããã¨ã ããã
ãã³ãã©ã¯èªåã®ç¶æ ã管çããã¦ã¼ã¶ã¯ãã®ä¸ã§é·ãæéãéããªãã®ã§ãseasideã®ãããªã¢ããã°ã¬ã¼ããã¹ã±ã¼ãªã³ã°ã®åé¡ããã¾ããªãã
Jinjaã®ãããªLuaã®ã·ã³ã¿ãã¯ã¹ã使ã£ããã³ãã¬ã¼ã
500è¡ã®ãã¡ã¤ã«ã«åã¾ããã³ãã³ãå¶å¾¡ã¹ã¯ãªãããã¤ãã¦ãã
ãã³ãã©ã¯ZeroMQãä»ãã¦Mongrel2ã¨è©±ãã®ã§ãè¶ ã«ãã³ã¤ã¤æ°´å¹³ã¹ã±ã¼ãªã³ã°ãå¯è½ã
Tenguã¯ã¡ãã£ã¨å¿ããã¦ãã®Tirãæ¢ãä½è£ããªãã®ã§ãæå¿ã®Zedãã¡ã³ã¯è©¦ãã¦ããã°ã§å ±åãã¦ãã ããã