VMã®ã¹ã¿ãã¯æä½ (æªå®) Gaucheã®VMã¯ããåç´ãªã¹ã¿ãã¯ãã·ã³ã§ããã ã ããSchemeã®å ´åãfirst class continuationãå®ç¾ããããã«ã ã¹ã¿ãã¯ãã¬ã¼ã ããã¼ãã«ã»ã¼ããããããéã«ãã¼ãããã¹ã¿ãã¯ã«å¾©å ããããã¨ãã æä½ãå ¥ã£ã¦æ¥ãã®ã§ããã£ããããã¨èªåã§ãæ··ä¹±ãã¦ãã°ãæã¡è¾¼ããã¨ãããã å¾ã§æãåºããããã«ãããã«æ´çãã¦ãããã åºæ¬ã¬ã¸ã¹ã¿ ã¹ã¿ãã¯æä½ã«æ·±ãããããã®ã¯æ¬¡ã®ã¬ã¸ã¹ã¿ç¾¤ã ScmEnvFrame *env ç¾å¨ã®ç°å¢ã®ããããããããstatic linkãç´æ¥ã«ã¯ã æãå å´ã®éçã¹ã³ã¼ãã§è¦ãã¦ããç°å¢ãæãã¦ããã upãã¤ã³ã¿ãããã£ã¦ããã°ä¸ã®ç°å¢ã«è¡ãããupãã¤ã³ã¿ã¯NULLã§çµç«¯ãããã ScmContFrame *cont ç¾å¨ã®ã³ã³ãã£ãã¥ã¨ã¼ã·ã§ã³ãã¬ã¼ã ã®ãããã ããããactivatio
Schemeã¯ç¶ç¶(continuation)ã¨ãããããã¸ãå¼·åã§æè»ãªå¶å¾¡æ©æ§ãåãã¦ãã¾ããç¶ç¶ãç¨ããã°å¤§åè±åºãã³ã«ã¼ãã³ãçä¼¼ãã«ãã¿ã¹ã¯ãããã¯ãã©ãã¯ã¨ãã£ãç¹æ®ãªå¶å¾¡ãå¿ è¦ã¨ããããã°ã©ã ãå¹ççã«è¨è¿°ãããã¨ãã§ããã®ã§ãããããä¸æ¹ã§ãã®æ½è±¡åº¦ã®é«ãããããç¶ç¶ã¯é£ãããã®ãã¨ããå°è±¡ãå¼·ãããã§ãã ããã§ã¯ç¶ç¶ã®æ£ç¢ºãªå®ç¾©ã¯ã¨ããããå¾ã«åããç´æçãªè¦³ç¹ããç¶ç¶ãå°å ¥ãã¦ã¿ããã¨æãã¾ãã 話ãç°¡åã«ãããããä»å ¨ã¦ã®æç¶ãã1-in/1-outã§ãããããª1-Schemeã¨ãããã®ãèãã¾ããä¾ãã°ï¼ (define (double x) (* x x)) (double 2) => 4 (define (add1 x) (+ x 1)) (add1 2) => 3 ã®ãããªæç¶ãã1-Schemeæç¶ãã§ãã (ãªãSchemeã§ã¯lambdaãèªç±ã«å°å ¥ã§
Last update 1999/08/07 Schemeå¦çç³»ã®å¶ä½ 第3å (C)平山ç´ä¹ ç¡æ転è¼ã¯ç¦æ¢ããªã³ã¯ã¯ããªã¼ 誤åè±åã®ææã¯æè¿ ç¶ç¶ã¨ã¯ ä»åã¯ãååãããã©ããããã¨æ¾æ£ããç¶ç¶ã®æ¦å¿µã®èª¬æããã³å®è£ ã¬ãã¼ãã«ã¤ãã¦æ¸ãããã¨æãã¾ãã ããããã¾ãã¤ã³ã¿ã¼ãããæ¼ã£ã¦ã¿ãã®ã§ããããã£ã±ãã©ããæ¥æ¬èªãªã½ã¼ã¹ã¯ãªããããã®ã§ãèªåã§æ¸ãã¦ã¿ããã¨ã«ãã¾ãï¼schemeã®ç 究ãã¦ãå¦è ã»å¦çãªãã¦æãã¦æ¨ã¦ãã»ã©ããã ããã«â¦â¦ï¼ ãã¦ããããªCè¨èªã®ã³ã¼ããããã¨ãã¾ãã void foo(void){ bar(baz( )); bar(0); } Cè¨èªãå¦ãã çãããªãããã®ã³ã¼ããã©ãããé çªã«å®è¡ãããã®ããããã¾ãããã説æãããã¾ã§ããªãã baz( )ãå¼ã³åºã ãã®æ»ãå¤ãå¼æ°ã¨ãã¦barãå¼ã³åºã 0ãå¼æ°ã¨ãã¦å¼ã³åºã fooã®å¼ã³åºããã¨ã«å¸°
ç¶ç¶ãcontinuationã¨æ¥ãã°ãã¯ãSchemeã®è©±ã«ãªãã®ã ããããä¸è¬ç¤¾ä¼ã§ schemeã¨è¨ãã°ãããã¼ãï¼nï¼è¨ç»ãé°è¬ããã§ãããã½ããã¦ã§ã¢æ¥ç㧠Schemeã¨è¨ã£ããLispã®ä¸ç¨®ã®ãã¨ã ãLispã«ã¯å¤ç¨®ãè ãã»ã©åå¨ãããã Common Lispã¨ä¸¦ãã§æåãªã®ãSchemeã§ãããCommon Lispãæ¨æºåã®èª²ç¨ã§ã´ã ã´ãã¨è£ åãã¦å·¨å¤§åããã®ã«å¯¾ããSchemeã¯é¥ãã«ã³ã³ãã¯ãã§ã¯ãªã¢ãªä» æ§ãæã¤ãã¾ãSchemeã¨ã¯è¨èªã®ä¸è¬åã§ããããã®å®è£ ã«ã¯Gaucheã¨ã scmã¨ãguileã¨ãMIT Schemeãªã©ãããã ãã¦Call/CCãæ£å¼å称Call with Current Continuationãã«ã¤ã㦠説æããããCall/CCã¯ã¡ãã£ã¨è¦ã¯setjmp/longjmpã¨åãããã«è¦ããã®ã ãã ã¹ã¿ãã¯ãæ·±ããªãæ¹åã«ãã¸ã£
ç¶ç¶(continuation)ã¨ã¯ï¼å¼ãè©ä¾¡ãã¦ããéä¸ã®ããæç¹ã§ï¼ããã¾å¾ããã å¤ã使ã£ã¦ï¼ãã®å¾ã¯ä½ãè¨ç®ããã®ããã表ããã®ã§ããï¼ãã¨ãã°ï¼Scheme ã®é¢æ°å¼ã³ã ãã®å¼ãè©ä¾¡ããéã«ã¯ï¼ã¾ãé¢æ°ã¨ãã®å¼æ°ãè©ä¾¡ãã¦ï¼ãã® å¾ã§é¢æ°ã«å¼æ°ãé©ç¨ããï¼ ==> (+ (* 1 2) (* 3 4)) ;; ==> (+ 2 12) ;; ==> 14 14 ãã®å¼ã®å ´åï¼ã¾ãã+ã,ã(* 1 2)ã,ã(* 3 4)ããè© ä¾¡ããã®ã¡ï¼ã(+ 2 12)ããè©ä¾¡ããï¼ åé¨åå¼ã®è©ä¾¡ãå·¦ããå³ã¸é²ããã®ã¨ããã¨ï¼ ãã¨ãã°ï¼ã(* 3 4)ããè©ä¾¡ããå¾ã«ããã¹ãè¨ç®ï¼ã¤ã¾ãç¶ç¶ã¯ï¼ ããã¾å¾ãããå¤ã«2ãå ããã ã§ããï¼ãã®å¼ã®è©ä¾¡ãå®äºããããã«ã¯ï¼ Schemeã®ã·ã¹ãã ã¯ï¼ãã®ç¶ç¶ãç¥ã£ã¦ããªããã°ãªããªãï¼ ç¶ç¶ã¯ï¼ãä½ãè©ä¾¡ãã¦ï¼ãã®å¤ã«ãã£ã¦æ¬¡ã«ã¯ä½ãè¡ãã
ãã®é ç®ã§ã¯ãããã°ã©ã ã®ç¶ç¶ã«ã¤ãã¦è¨è¿°ãã¦ãã¾ãããç¶ç¶ãã®èªç¾©ã«ã¤ãã¦ã¯ãã¦ã£ã¯ã·ã§ããªã¼ã®ãç¶ç¶ãã®é ç®ãã覧ãã ããã è¨ç®æ©ç§å¦ã«ãããç¶ç¶ï¼ãããããcontinuationï¼ã¨ã¯ãããã°ã©ã ãå®è¡ä¸ã®ããæç¹ã«ããã¦ãè©ä¾¡ããã¦ããªãæ®ãã®ããã°ã©ã ï¼the rest of the programï¼ã表ç¾ãããã®ã§ãããæç¶ãï¼procedureï¼ãããã¯é¢æ°ï¼functionï¼ã¨ãã¦è¡¨ç¾ããããã®ã§ãã[1]ã ç¶ç¶ã«ç¸å½ããæ¦å¿µã¯1960年代åé ããåå¨ãã¦ãããAlgol 60ã®ã³ã³ãã¤ã©ã®å®è£ [2]ãªã©ã®æç®ã«ãã³ãã³ç»å ´ãã¦ããããç¶ç¶ã®å©ç¨ã«é¢ããæãæ©ãè¨è¿°ã¯ã1964å¹´ã®ã¢ããªã¢ã³ã»ãã¡ã³ã»ã¯ã¤ã³ãã¼ã«ãã³Â (en:Adriaan van Wijngaarden) ã«ãããã®ã§ãã[1]ã
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}