Created
November 11, 2012 12:59
-
-
Save ympbyc/4054834 to your computer and use it in GitHub Desktop.
Macraのコンパイラに遅延評価を実装
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 今、 | |
"!funcall !lambda x x 1" --#1 | |
-- をコンパルすると | |
Right (FrameInst HaltInst (ConstExpr 1.0 (ArgInst (CloseInst "x" (ReferInst "x" ReturnInst) ApplyInst)))) -- #2 | |
-- これで1を遅延させるには、thunkに包んでやる。 | |
!funcall !lambda x !funcall x nil !lambda nil 1 --#3 | |
-- コンパイルするとこうなる | |
Right (FrameInst HaltInst (CloseInst "nil" (ConstExpr 1.0 ReturnInst) (ArgInst (CloseInst "x" (FrameInst ReturnInst (ReferInst "nil" (ArgInst (ReferInst "x" ApplyInst)))) ApplyInst)))) -- #4 | |
-- Macraを遅延評価にするなら、#1を直接#4にコンパイルしてやればいい。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment