Rework environment mode fixes #8
This commit is contained in:
@@ -96,16 +96,15 @@ fn interpret_application(vec: &Vec<Datum>, env: &mut Env) -> Datum {
|
||||
let lambda_body = &v[2];
|
||||
let lambda_args = args[1..].to_vec();
|
||||
|
||||
// FIXME: this does not optimize tail-calls
|
||||
environment::extend_environment(lambda_parameters, List(lambda_args), env);
|
||||
let mut r = Datum::Unspecified;
|
||||
let mut new_env = environment::extend(lambda_parameters, List(lambda_args), env);
|
||||
if let List(seq) = lambda_body {
|
||||
for i in 0..seq.len() {
|
||||
r = interpret(&seq[i], env);
|
||||
for i in 0..(seq.len() - 1) {
|
||||
interpret(&seq[i], &mut new_env);
|
||||
}
|
||||
interpret(&seq[seq.len() - 1], &mut new_env)
|
||||
} else {
|
||||
panic!("INTERPRET-APPLICATION -- no-list {:?}", lambda_body)
|
||||
}
|
||||
environment::shrink_environment(env);
|
||||
r
|
||||
}
|
||||
_ => panic!("INTERPRET-APPLICATION -- not-aplicable {:?}", args[0]),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user