On 10/05/2013 16:19, Alexander Burger wrote:
you cannot do TCE while interpreting List structures. You have to do
it in the compiler, as it requires some analysis of the code structure.
One could always look ahead and try to analyse the s-expression's
structure while executing it... this probably wouldn't perform very well
though.
I think we are thinking the same thing, just from different perspectives
:). You could conceivably write an interpreter for pure list data that
eliminated tail calls, because you can write an interpreter that can do
anything, but it wouldn't be an optimisation because of the extra overhead.
Please avoid the term "dynamic scope". There is no such thing in
PicoLisp. PicoLisp has "dynamic binding".
Indeed, sorry about that.
Still, using the correct term, unless I'm gravely mistaken the presence
of it necessarily forbids one from even considering general TCE, as it
would demand messing with the bindings at the wrong times.
Anyway, I think PicoLisp's incredible dynamic programming power can
probably supply better solutions than asking the interpreter to do TCE
for you (e.g. a self-compiling function that you define in recursive
form and rewrites itself to use iteration the first time it runs; I have
no idea to do this but I'm sure someone already has).
AlexG
--
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe