为什么这三个函数不像第一个函数那样返回未求值的参数?有没有办法让后两个函数也像第一个函数那样工作?在函数内部,e 仍然是未求值的,这似乎是在返回结果时发生的。
names default to here(1);
ns = New Namespace("n");
foo = function({e}, Name Expr(e) );
ns:bar = function({e}, Name Expr(e) );
show( foo( expr( notavar ) ) ); // expected returns notavar, unevalauted
show( here:foo( expr( notavarhere ) ) ); // unexpected tries to evaluate notavarhere
show( ns:bar( expr( notavarns ) ) ); // unexpected tries to evaluate notavarns
正如预期的那样,函数内部的 e 没有被求值:
ns:bart = function( {e}, Show( Name Expr(e) ) );
ns:bart( expr( notavar ) ); // expected, unevaluated
虽然将函数复制到当前默认命名空间是一种不太理想的解决方法,但这并不能解决嵌套函数调用的问题。
localbar = name expr( ns:bar );
show( localbar( expr( notavar ) ) ); // expected, unevaluated