[Tailcall optimization Adrian Prantl **20090126210856] { hunk ./compiler.fs 12 +Create tailcall-flag 0 , hunk ./compiler.fs 41 +: tailcall? ( -- b ) tailcall-flag @ ; hunk ./compiler.fs 164 +: .? ( c -- b ) [Char] . = ; hunk ./compiler.fs 515 - query? not if s" wam-deallocate" push-xt; endif - s\" s\" '" push-xt - push-functor s\" -clause-1\" pl-execute" push-xt; -; + tailcall? if + query? not if s" wam-deallocate" push-xt; endif + s\" s\" '" push-xt + push-functor s\" -clause-1\" pl-execute" push-xt; + else + s\" s\" '" push-xt + push-functor s\" -clause-1\" pl-call" push-xt; + endif ; hunk ./compiler.fs 592 +: set-tailcall-flag ( addr u -- ) 2dup skip-ws peek .? tailcall-flag ! 2drop ; + hunk ./compiler.fs 606 - ['] args paren { addrR uR } + ['] args paren + + set-tailcall-flag { addrR uR } + hunk ./compiler.fs 647 - ['] args paren { addrR uR } - addrF uF goal + ['] args paren \  process args + + set-tailcall-flag { addrR uR } + + addrF uF goal \  compile.. hunk ./compiler.fs 759 -s" :- concatenate(A,B,[a,b])." compile eval bye - -s" :- compare_terms(Y,a,b)." compile eval +s" :- concatenate(A,B,[a,b])." compile eval hunk ./compiler.fs 767 +s" :- compare_terms(Y,a,b)." compile eval bye hunk ./compiler.fs 769 - }