do not suppose in eval that list first element is function

This commit is contained in:
VaclavT 2021-05-04 19:59:49 +02:00
parent 5ca8f64853
commit 358414d7d3
1 changed files with 12 additions and 12 deletions

24
ml.cpp
View File

@ -729,20 +729,20 @@ MlValue MlValue::eval(MlEnvironment &env) {
args = std::vector<MlValue>(list.begin() + 1, list.end());
// Only evaluate our arguments if it's not builtin!
// Builtin functions can be special forms, so we
// leave them to evaluate their arguments.
function = list[0].eval(env);
if (function.type == BUILTIN || function.type == LAMBDA) {
// Only evaluate our arguments if it's not builtin!
// Builtin functions can be special forms, so we
// leave them to evaluate their arguments.
if (!function.is_builtin())
for (size_t i = 0; i < args.size(); i++)
args[i] = args[i].eval(env);
if (!function.is_builtin())
for (size_t i = 0; i < args.size(); i++)
args[i] = args[i].eval(env);
MlPerfMon::instance().add_method_call(function.type == LAMBDA ? "lambda" : function.str);
res = function.apply( args, env );
MlPerfMon::instance().end_method_call();
return res;
MlPerfMon::instance().add_method_call(function.type == LAMBDA ? "lambda" : function.str);
res = function.apply(args, env);
MlPerfMon::instance().end_method_call();
return res;
}
default:
return *this;