Vito Van
2016-08-10 10:07:17 UTC
æè¿åšè¯»ãOn LispãïŒçå°ç¬¬12ç« ç¬¬4å°èæ¶æäžäºäžæçœä¹å€ïŒåšæ€ååäœè¯·æïŒ
ç« èåšçº¿é 读ïŒ
http://www.ituring.com.cn/article/53771
ïŒCtrl+FïŒ12.4 æŽå€æçå®çšå·¥å ·ïŒ
è¿äžéšå诎éèŠè®Ÿè®¡äžäžªå® _f ïŒå¯ä»¥ç解䞺ïŒ
(_f + x y) çåäº (incf x y)
ç¶åç»åºäºäžäžªé误çäŸåïŒ
(defmacro _f (op place &rest args) ; wrong
'(setf ,place (,op ,place ,@args)))
é误çåå æ¯ïŒâäžå¹žçæ¯ïŒæ们æ æ³çš define-modify-macro æ£ç¡®æ 误å°å®ä¹ _f ïŒå 䞺åºçšå°å¹¿ä¹åéäžçæäœç¬Šæ¯ç±åæ°ç»å®çãâïŒæ没æç解ïŒäžºä»ä¹âåºçšå°å¹¿ä¹åéäžçæäœç¬Šæ¯ç±åæ°ç»å®çâå°±äžèœæ£ç¡®æ 误çå®ä¹ _f äºå¢ïŒ
æè¯äºè¯è¿äžªé误çäŸåïŒåŽä¹æ²¡åç°ææŸçé误ïŒè¿è¯·åäœåž®å¿è§£çäžäžïŒææ¿äžå°œïŒ
以äžäžºé误ç _f çå±åŒïŒ
CL-USER> (macroexpand '(_f * x 10))
(SETQ X (* X 10))
T
CL-USER> (macroexpand-1 '(_f * (get 'prop x) 10))
(SETF (GET 'PROP X) (* (GET 'PROP X) 10))
T
CL-USER> (macroexpand-1 '(_f * (incf (aref a (incf i))) 10))
(SETF (INCF (AREF A (INCF I))) (* (INCF (AREF A (INCF I))) 10))
T
ç« èåšçº¿é 读ïŒ
http://www.ituring.com.cn/article/53771
ïŒCtrl+FïŒ12.4 æŽå€æçå®çšå·¥å ·ïŒ
è¿äžéšå诎éèŠè®Ÿè®¡äžäžªå® _f ïŒå¯ä»¥ç解䞺ïŒ
(_f + x y) çåäº (incf x y)
ç¶åç»åºäºäžäžªé误çäŸåïŒ
(defmacro _f (op place &rest args) ; wrong
'(setf ,place (,op ,place ,@args)))
é误çåå æ¯ïŒâäžå¹žçæ¯ïŒæ们æ æ³çš define-modify-macro æ£ç¡®æ 误å°å®ä¹ _f ïŒå 䞺åºçšå°å¹¿ä¹åéäžçæäœç¬Šæ¯ç±åæ°ç»å®çãâïŒæ没æç解ïŒäžºä»ä¹âåºçšå°å¹¿ä¹åéäžçæäœç¬Šæ¯ç±åæ°ç»å®çâå°±äžèœæ£ç¡®æ 误çå®ä¹ _f äºå¢ïŒ
æè¯äºè¯è¿äžªé误çäŸåïŒåŽä¹æ²¡åç°ææŸçé误ïŒè¿è¯·åäœåž®å¿è§£çäžäžïŒææ¿äžå°œïŒ
以äžäžºé误ç _f çå±åŒïŒ
CL-USER> (macroexpand '(_f * x 10))
(SETQ X (* X 10))
T
CL-USER> (macroexpand-1 '(_f * (get 'prop x) 10))
(SETF (GET 'PROP X) (* (GET 'PROP X) 10))
T
CL-USER> (macroexpand-1 '(_f * (incf (aref a (incf i))) 10))
(SETF (INCF (AREF A (INCF I))) (* (INCF (AREF A (INCF I))) 10))
T
--
--
Lisp-cn(Lispäžæçšæ·ç»)
CLUG http://lisp.org.cn
---
æšæ¶å°æ€é®ä»¶æ¯å 䞺æšè®¢é äº Google çœäžè®ºåçâLisp-cn(Lispäžæçšæ·ç»)â矀ç»ã
èŠé订æ€çŸ€ç»å¹¶åæ¢æ¥æ¶æ€çŸ€ç»ççµåé®ä»¶ïŒè¯·åéçµåé®ä»¶å°lisp-cn+***@googlegroups.comã
èŠæ¥çæŽå€é项ïŒè¯·è®¿é® https://groups.google.com/d/optoutã
--
Lisp-cn(Lispäžæçšæ·ç»)
CLUG http://lisp.org.cn
---
æšæ¶å°æ€é®ä»¶æ¯å 䞺æšè®¢é äº Google çœäžè®ºåçâLisp-cn(Lispäžæçšæ·ç»)â矀ç»ã
èŠé订æ€çŸ€ç»å¹¶åæ¢æ¥æ¶æ€çŸ€ç»ççµåé®ä»¶ïŒè¯·åéçµåé®ä»¶å°lisp-cn+***@googlegroups.comã
èŠæ¥çæŽå€é项ïŒè¯·è®¿é® https://groups.google.com/d/optoutã