2004-01-01ãã1å¹´éã®è¨äºä¸è¦§
;å¤æ°ãã¼ãã«globaléå§ (define x "X") (define incr #t) ;å¤æ°ãã¼ãã«letéå§ (let ((x 0)) (set! incr ;å¤æ°ãã¼ãã«lambdaéå§ (lambda () (begin (set! x (+ x 1)) x)) ;å¤æ°ãã¼ãã«lambdaçµäº )) ;å¤æ°ãã¼ãã«letçµäº (incr) ;å¤æ°ãã¼ãã«lambdaâ¦
Schemeã®ç¶ç¶ãå®è£ ããããã«ã¯ç¶ç¶ããªãã¸ã§ã¯ãã¨ãã¦æ±ããªãã¦ã¯ãªããªããããã¦ãç¶ç¶ããªãã¸ã§ã¯ãã¨ãã¦æ±ãã®ãªãã°CPSã¸ã®å¤æã¨ãã¦æ¸ãã®ãè¯ãã®ã§ã¯ãªãã(ã¨ãããããä»ã®æ¸ãæ¹ãæãã¤ããªã)ã 以ä¸ã¯ã¡ã¢ã ã¾ããæ¼ç®ã®æå°è¦ç´ ã¨ãâ¦
((object 'symbol) args...) => (method args...) => returnValueããã§ã¯objectã¨methodã®åæ¹ã«å¯¾ãã¦ã»ã¼ç価ãªæ§æãå©ç¨ãã¦ãããobjectã¯ã·ã³ãã«ãåãåããmethodã¯å¼æ°ã®ãªã¹ããåãåãã¨ããç¹ã ããå¯ä¸ç°ãªã£ã¦ãããMethod dispatchã«ãã£â¦
((object 'method) args...) ã¨ãã(æãåç´ãª)æ§æãæãã¤ãããJavaã®æ§æã¨çµæ§ä¼¼ã¦ãããããªæ°ãããã (define make-closure (lambda (_x) (let ( (x _x) ) (lambda (method . parameter) (cond ( (eq? method 'x) x) ( (eq? method 'setx1) (lambdaâ¦
Schemeã®ã·ã³ãã«ã¯ããã¾ã§ãã·ã³ãã«ã¨ãããã¼ã¿åã®ä¸ã¤ã«ãããªããããããåæã«å¤æ°ã®èå¥åã¨ãã¦ãå©ç¨ããã¦ãããè©ä¾¡ããã¨ãã®ã·ã³ãã«ã«æç¸ãããå¤ãè¿ãããã«ãªã£ã¦ããã ãã®ããã«lisp/Schemeã§ã¯ä¸ã¤ã®è¦ç´ ã§ãã£ã¦ããã®å±é¢ã«å¿ãâ¦
SchemeããClassãå®ç¾©ããã®ãªãå¿ ç¶ã¨ãã¦åçãªãã®ã«ãªã訳ã§ããããã¿ã¤ãã³ã°ã«ã¯ä¾¿å©ãããããªããããã«ããããcompileãã¦Javaã«éå ãã(ã¨ãåºæ¥ããè¯ããª)ã
Javaã§ã¯fieldã¨method(ã¨class)ã®åå空éãåºå¥ããã¦ãã*1ããSchemeã§ã¯å¤ã¨é¢æ°ã®åå空éãåºå¥ããã¦ããªããé©å½ã«æ¦ãåããã¦ãããæ¹ãè¯ãã ããã (class 'classpath)ã§Javaã®ã¯ã©ã¹ãå¾ãã (object 'field)ã§object.fieldãå¾ãã åé¡ã¯objâ¦
Schemeå´ã®ãã¼ã¿åãjava.lang.Objectãç¶æ¿ãã¦ãããã¤ã¾ããScheme Nativeãªè¦ç´ ã¯å®è£ ä¸ãåæã«Java Nativeãªãªãã¸ã§ã¯ãã§ããããã®å ´åã Scheme Nativeãªè¦ç´ ãJavaã®ç¶æ¿ããªã¼ä¸ã§ã¯ä¾å¤äºé ã¨ãã¦æ±ããJava Nativeãªãªãã¸ã§ã¯ãã¨ãã¦ã¯æ±ãâ¦
æ£æã«ã§ãçé¢ç®ã«å®è£ ãã¦ã¿ããããªãã¨ãã訳ã§ãã®æ¹éãèãã¦ã¿ãã Schemeãã¼ã¹ ãã¼ã¿åããã¢ãâ¦â¦ãªã©ãScheme Nativeãªè¦ç´ ã¯ããããä¸ã¤ã®ã¯ã©ã¹ã¨ãã¦å®è£ Scheme-Javaæ¥ç¶ Java Nativeãªãªãã¸ã§ã¯ãã¯é¢æ°ã¨ãã¦æ±ã*1 Javaã®primitiveå¤ã¯â¦
reflectionã®ãããªãã¨ãJavassistã§è¡ãã°ã確å®ã«çã®Javaã¨åãé度ãåºããããã ãç¾è¡ã®reflectionãJITãå¹ãã°å åã«éãã®ã ãããJavassistã«ããã¡ã¢ãªæ¶è²»ãåé¡ã«ãªããããããªããâ¦â¦ãã以åã«ã©ã¤ã»ã³ã¹ã®åé¡ããããªã
ç§ãèãã¦ããåã¯ãå¥ç´ããªãã¸ã§ã¯ãåãããã®ãã ã£ããã¨ã«æãè³ã£ãã
Scheme風å³ã®ã¹ã¯ãªãããjavaã§å®è£ ãã¦ã¿ããç¹å¾´ã¯ä»¥ä¸ã®éãã GCã¯javaã«ä»»ããã javaã®reflectionãå¤ç¨ããã*1 ç¶ç¶ã¯æªå®è£ ã *1:displayãjava.lang.System.out.printlnã¸ã®åç §(ã¨ãã®å®è¡æ¹æ³)ã ã£ããã
Q.ãªãæ¼åºè¡ã¨ãã¦ã®ãªã¢ãªãºã ãæ¼åºã®æ¾æ£ãè¨æãããã®ã«ãããªãã®ãã A.ããããè¿ä»£å°èª¬ã¯ãªã¢ãªãºã ãåæã¨ãã¦ããããã§ããã*1 *1:ããæ°ä½ä¸ä¸
http://www.kmonos.net/alang/etc/merd.php ä½ã¨ããããç§ã®èãã¦ãããã®ã«ããªãè¿ããã®ãçºè¦ã
æè¿ã¯Schemeã触ã£ã¦ããã®ã ããä½ã§ãåºæ¥ãè¨èªã¯ãã®åã ãå¯è½æ§ãèæ ®ããªãã¦ã¯ãªããªãããã«ä½¿ãã«ãããªãã®ã§ã¯ãªããã¨æãã 大æ¦ã®ããã°ã©ãã³ã°è¨èªã¯ãã¥ã¼ãªã³ã°å®å ¨(ã¨ããããããã¥ã¼ãªã³ã°å®å ¨ã§ãªããã°ããã°ã©ãã³ã°è¨èªã¨ãã¦å¤±â¦
ãªã¢ãªãºã ã¨ã¯æè ã®æ¼åºè¡ã§ãã(è¨ãéã)ã ãªã¢ãªãºã ã«åºã¥ããæ¼åºãããèªèº«ä½è ããçã¿åºããã¨ã¯ç¨ã ããã¡ãããæ¢ã«åå¨ããä½è ããä¼ããããã«ã¯æè¯ã®ææ³ã«ãªãã®ã ããä¸æ¦ã«å¦å®ãããã¨ãåºæ¥ãªãã®ã ããå°ãªãã¨ãæ¼åºè¡ã¨ãã¦ãªã¢ãªâ¦
èªè ã®å¤§åã¯ãä½è ã®æã£ã¦ãããããªçæ³çèªè ï¼æ¶è²»è ã§ã¯ãªãã以ä¸ã§ã¯éçæ³çèªè ãé¡ååãã¦ã¿ããã ãã£ãã å½¼ãã¯ç±å¿ãªèªè ã§ãããä½åã®åºç¤ï¼å½¼ããç©èªã«æ²¡å ¥ããäºåã°ããåã®ãã¨ã ï¼ã«èª¬æãããäºæãçµç¤ã¾ã§è¦ãã¦ãããã¨ã¯å°ãªâ¦
ã¸ã£ã³ã«è«ã¯å¸¸ã«ä¸æ¯ã§ãããè¬ãããªãããã¯äº¤é種éã®åé¡å¦ã ããã§ããã çç©åé¡å¦ã®å ´åãå¤ä»£ããè¿ä»£ã¾ã§ã«äºã£ã¦åç©å¦ã®ç¥èã«åºã¥ããåé¡ãè¡ããã¦ããããã®ãããçºè¦è ã®å°è±¡ã ãã§æ±ºãããªã©ãæ£æçãªå¤æãç¹°ãè¿ããã¦ãããããã«å¯¾â¦
äºåï¼å¾æ¡ä»¶ã«ã¤ãã¦ä¸ã¤éè¦ãªãã¨ã«æ°ãä»ããã ãã©ã¡ã¼ã¿ä»ãåæ´åæ§ã«ããæ¤è¨¼ã(ããåå§çãª)assertã«ããæ¤è¨¼ãããåªãã¦ããã®ã¯ãäºåï¼å¾æ¡ä»¶ãå¤é¨ã«å ¬éããã¦ããã¨ããç¹ã§ããã
åãããã³ã°ãæ§æã«å«ãã°*1ãã¦ã³ãã£ã¹ããç¡ããããããªæ°ãããã if( object instanceof TypeA){ TypeA objectAsTypeA = (TypeA) object; // do Something. } else if( object instanceof TypeB){ TypeB objectAsTypeB = (TypeB) object; // do Someâ¦
å¼æ°ã®åã¯äºåæ¡ä»¶ã®ä¸ç¨®ã ãè¿å¤ã®åã¯äºå¾æ¡ä»¶ã®ä¸ç¨®ã ãã¨æãã¤ãã¦ããæ¤ç´¢ãããEiffelãåºã¦ããã ãå³å¯ãªäºåï¼å¾æ¡ä»¶ãæãç«ã£ã¦ãããã©ãããã調ã¹ãããã«ã¯åä½æ¡ä»¶ã§ã®æ¤è¨¼ãå¿ è¦ã«ãªãã®ã ããåä½æ¡ä»¶ã§ã®æ¤è¨¼ã§ã¯ãäºåï¼å¾æ¡ä»¶ã常ã«â¦
Haskellãè¦ã¦æã£ããéåã¨åã¯ãã°ãã°çããã Booleanåã¯[true, false]ã¨ããéåã«çãããIntegeråã¯[MinimumInteger,MinimumInteger+1,...,MaximumInteger-1,MaximumInteger]ã«çãããå®éã«ã¯ä»»æé·ã®é åãªã©ãè¦ç´ ã®æ°ãæéåã«åã¾ããªã*1â¦
smalltalkãè¦ã¦æã£ããã¡ãã»ã¼ã¸ã³ã°ãæ確ã§ããã°å åã ã object.method(); object.field; ã¨ã¯ã¤ã¾ãã object ã¡ãã»ã¼ã¸ã³ã°å .method,.field ã¡ãã»ã¼ã¸ï¼.ãã¡ãã»ã¼ã¸ã³ã°è¨å·ãmethod,fieldãã¡ãã»ã¼ã¸å å®¹ï¼ () ãããã¡ãã»ã¼ã¸
lispãè¦ã¦æã£ããå¼ã¨å¼ã¨ã®ã»ãã¬ã¼ã¿ããããã°å åã ã å¼1;å¼2;...;å¼N ã¯æãN-1åã¨å¼ã1åã§ã¯ãªããè¤æ°ã®å¼ãåæããä¸ã¤ã®å¼ã ã¨ã¿ãªãã¦ãæ§ããªãã (begin å¼1 å¼2 ... å¼N) ã¨åããããªæãã
ãã¦ããã¡ã¿ãã£ã¯ã·ã§ã³ãã§ããã ããã£ã¯ã·ã§ã³ãã¨ã¯æ£æå½¢å¼ã§æ¸ãããåµä½ç©èªå ¨è¬ã§ãããä¸è¬ã«ãã¡ã¿ãã£ã¯ã·ã§ã³ãã¨å¼ã¶ã¨ãã«ã¯åµä½ç©ã¨ãã¦ã®å´é¢ã«ã¤ãã¦çç®ãããªããã¤ããã£ã¯ã·ã§ã³ãã¨ããèªãå帰çã«é©ç¨ãããã¡ã¿åµä½ãçåµä½ç©èªâ¦
ãã¡ã¿âÃãã¨ããè¨èãéããã«ã¯ãâÃãã«é¢ããå ±éèªèãå¿ è¦ã§ããã ãâÃããå ·è±¡ç©ã§ããå ´åã«ã¯ãããªãã«å ±éèªèãå¾ãããå¯è½æ§ãé«ããç§ãä»æã£ã¦ãããã¼ãã¼ãããç§ãä»æã£ã¦ãããã¼ãã¼ããã§ãããã¨ã«ã¤ãã¦å ±éèªèãããã¨ã¯å¿ ããâ¦
ä¸å£ã«ãã¡ã¿ãã¨è¨ã£ã¦ããã®å å®ã¯æ§ã ã§ããããããããæ¥é è¾ã¨ããéç¬ç«èªã§ãããã¨ãããé£æ³åºæ¥ãããã«ããã®å¾ã«ç¶ãè¨èã象徴ãããã®ã«ãã£ã¦åãã¦ãã®æå³ãå®ã¾ããããã®å¾ã«ç¶ãè¨èã象徴ãããã®ããå¤ç¾©çã§ããã°ããã»ã©ãã¡ã¿âÃâ¦
å¯è½æ§ç©(ä»®)ã®å©ç¹ã¨ã¯æ å ±éã®é©æ£åãè¨ãããã¨ã§ãããæ å ±éã®é©æ£åãããç©èªã¯å°ãªãã¨ã以ä¸ã®ä¸ç¹ã§åªä½ã§ããã ä¼ç·ã®åå¨ãæ°ä»ããããããªãã ä¼ç·ã®æ´»ç¨ãç´å¾ããããããªãã ã¡ã¿ã¬ãã«ã§ã®è¨è¿°ãæ··å ¥ãã«ãããªãã*1 *1:ã¡ã¿ã¬ãã«ã®â¦
å¯è½æ§ç©ã§ã¯é¸æè¢ãä»»æã®æ°ã«èª¿æ´ãããã¨ãåºæ¥ããã¤ã¾ãããããã®ã¨ãã«Gainã®æ大å¤ã¨ããå¤ãå¾ããããCostã®è©ä¾¡ãèªè ã«ãã£ã¦ç°ãªããã¨ã¯æãããªã®ã§ãã¸ã£ã³ã«ã®éããã¤ã¾ãã¯å¯¾è±¡ã¨ããèªè 層ã®éããã«å¿ãã¦é¸æè¢ã®æ°ãå¢æ¸ãããã¨ãâ¦
æ°è©±ã§ã¯è½åãå¯è½æ§ã¨ãã観ç¹èªä½ãå¸èã§ãã*1ãå ¨ã¦ã®åºæ¥äºã¯èµ·ããã¹ããã¦èµ·ããã®ã§ãããããããé¸æè¢èªä½ãåå¨ããªãã éã«è¿ä»£å°èª¬ã§ã¯åç»å ´äººç©ãå é¢ãæã¡ï¼æã¤ãã¨ã«ãªã£ã¦ãããä½è ã®é½åãå¥ã¨ããã°ããããé¸æè¢ãé¸ã¶ãã¨ãåºâ¦