- ããã°ã©ããã³ã¼ãä¸ã«æ¸ãããã¯ã
- ãã¯ãå±éã«ãã£ã¦åºç¾ãããã¯ã
ãã¹ã¦ãå±éãããå¾ã«è©ä¾¡ãããããã ã¨ããå
å
¥è¦³ããã£ãã
ã ãã©ãid:yagiey:20100223:1266942998ããããããã®å
å
¥è¦³ãçãããæãå§ããã
ä¾ãã°æ¬¡ã®ãããªå ´å
gosh> (define-macro (_if test e1 . e2) `(if ,test ,e1 . ,e2)) #<undef> gosh> (define-macro (_or . args) (cond ((null? args) #f) ((null? (cdr args)) (car args)) (else (let ((tmp (gensym))) `(let ((,tmp ,(car args))) (_if ,tmp ,tmp (_or . ,(cdr args)))))))) #<undef> gosh> (macroexpand '(_or #f #f 42)) (let ((#0=#:G2 #f)) (_if #0# #0# (_or #f 42)))
ä¸åãã¯ãå±éããã ãã ã¨ãæ·±ãã¨ããã«ãã_ifã_orã¯å±éãããªãã
ã¤ã¾ããä¸åç®ã®ãã¯ãå±éã«å¾ç¶ããä½ããã®è¨ç®ã§ãããã«ãã¯ãå±éãè¡ãããã¨ãããã¨ã ãªãã¤ã¾ããåã®å
å
¥è¦³ãééã£ã¦ããããã ãªã
ããã¨ãmacroexpandã¯é常ã®è©ä¾¡ã®æ§åãåæ ããªãã£ããããã®ããªï¼
ã¾ãä¸æ¹ã§
gosh> (define-macro (hoge) (+ 1 2)) #<undef> gosh> (macroexpand '(hoge)) 3
ã®ããã«ããã¯ãå±éæã«ãæ®éã«æç¶ãã®è©ä¾¡ãè¡ãããã
LISPã®ãã¯ãå±éãå©ç¨ããããã°ã©ãã³ã°ãã¡ã¿ããã°ã©ãã³ã°ã¨ã¨ãããã¨ã
- ãã¯ãå±é
- ãã¯ãå±é以å¾ã®è¨ç®
ã¨ãã2ã¤ã®è¨ç®ã·ã¼ã³ãããã¨ããã¤ã¡ã¼ã¸ããã£ã¦ããããC++ã®ãã³ãã¬ã¼ãã¡ã¿ããã°ã©ãã³ã°ã¨ãããããã ããããã¯ãå±éã¯ãã以éã®ãã¹ã¦ã®è¨ç®ã«å ç«ã¤ã¨ããå å ¥è¦³ããã£ãã
ã©ããããLISPã®ãã¯ãå±éã¯ãèªåãæã£ã¦ããã»ã©ç¹å¥ãªåå¨ã§ã¯ãªãããã ããã¯ãå±éã¨ãã以å¤ã®è¨ç®ã¯äºãã«å調ãã¦åãã¦ããããã ã
ããããã¯ãå±éã¯ãå
·ä½çã«ã¯ãã¤è¡ããããã ããã
ãã®ã¨ã³ããªã®Schemeã®ã³ã¼ãã¯Gaucheã§ãã確ããã¦ãªããã©ããããããããã¹ã¦å¦çç³»ä¾åãªè©±ãã ã£ãããããã®ããªã
ä¸æ¯ãªèå¯ã ã£ãï¼ï¼ï¼
ã³ã¡ã³ãã®éãã
ããããä¼çµ±çãã¯ãã¯è¦æ ¼ã«ããã¾ãããæªå®ç¾©ã§ãã
ã¨ãããã¨ãããã
ããããªãããããããããããããã¼ã¼ã¼ã¼ã¼
ããã¾ã§å¥½ãã«ããã¨ãã¦åæã«å¥½ãã«ãªã£ãã¯ãªããããªã
ã³ã¡ã³ãæ¬ãã¾ã¨ãã¦ã¿ãï¼2010/03/15 00:09ï¼
ã³ã¡ã³ãæ¬ãããã...ã
SaitoAtsushiãããshiroããããããã¨ããããã¾ããã
ã¾ããèªåãã¦ãã¦ãèãã¦ããã¨ã¸ã®çã
- macroexpandã¯ä¸çªå¤å´ã®ãã¯ãããå±éããªã
- ãã¯ãå±éã¯ãã¹ã¦ã®è¨ç®ã«å ç«ã£ã¦è¡ããã
ã ããã ã
å¾è
ã¯ææ°è¦æ ¼ï¼r6rsããªï¼ï¼ã§ã¯ã£ãã決ããããããã ã
ãã¨ããã¤ãéè¦ãªæ å ±ãé ããã
- r5rsã§ã¯ä¼çµ±çãã¯ãã¯è¦æ ¼å¤
- r6rsのマクロに関するドキュメント
- ãã¯ãå±éã®ã¿ã¤ãã³ã°ã¯ãä¼çµ±çãã¯ããå¦ãã«ã¯é¢ä¿ãªã
- syntax-caseã¨ãããã¯ãã使ãã°ä¼çµ±çãã¯ããå®è£
ã§ããï¼gaucheã¯r6rsãããªããã©syntax-caseã使ããï¼
- ããã°ã©ãã³ã°Gaucheã®272ãã¼ã¸è注ãGaucheã¯è¿ãå°æ¥ãã³ã³ãã¤ã©ã«çµ±åãããsyntax-caseããµãã¼ãããäºå®ã§ãããï¼ä»¥ä¸ç¥ï¼ã
- SCMã¨ããå¦çç³»ã¯ãã¯ãå±éã®ä»çµã¿ãgaucheã¨ã¯ç°ãªã£ã¦ããï¼ç¾å¨ã¯ã©ããæªç¢ºèªï¼
- ããã®ãã¯ããã©ã¼ã ãåãã¦å®è¡ãããæç¹ã§å±éãããå±éçµæãã¡ã¢åããããã¨ããå®è£
ããããããããã°ãã£ã¦ã¦ããã£ãï¼
åããã¤ãå¦çç³»ãå®è£
ãã¦ã¿ãããªãã