Closed mathroc closed 9 years ago
There's also no real need for getValue
in functions just yet, so I won't add it.
well, source
returned by getValue()
for function is actually useful for the \ast
command in the REPL (see #24). or maybe it should be some other name ?
oh, I finally understood what's wrong. when calling execute
, the first argument needs to be an AST, but in if
and ifelse
it "just" a function so ast,length
is undefined
and nothing happens.
so it should be either [trueCase, {type: 'invoke'}]
or trueCase,getValues()
or just trueCase.invoke(stack, scope);
as you just pushed ^^
I think I'll make execute
use forEach
to iterate over the array. for (var i = 0; i < ast.length; i++)
is an anachronism, and this'll make failure more obvious.
:+1:
No, using
getValue()
won't work for internal functions. I just needed to rewrite it in terms of.invoke()
, so(condition.getValue() ? trueCase : falseCase).invoke();