From 98e84b28a23f2b832409503c11f2065123746a89 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Thu, 21 Apr 2016 02:41:41 -0400 Subject: rust: more fiddling with procedure application lifetime warning --- minimal.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/minimal.rs b/minimal.rs index 876d164..0372124 100644 --- a/minimal.rs +++ b/minimal.rs @@ -368,8 +368,8 @@ fn apply_action<'a>(list: &'a Vec, ctx: HashMap<&'a str, SchemeExpr< match head { SchemeExpr::SchemeProcedure(ref binds, ref body, ref proc_ctx) => { // This block of code implements procedure (lambda) application - if body.len() == 0 { - return Err("prodedure must have non-empty body"); + if body.len() != 1 { + return Err("prodedure must have single-expression body"); } let mut closure = proc_ctx.clone(); if binds.len() != args.len() { @@ -378,15 +378,9 @@ fn apply_action<'a>(list: &'a Vec, ctx: HashMap<&'a str, SchemeExpr< for (name, arg) in binds.iter().zip(args) { closure.insert(name, arg); } - /* XXX: Almost Working... - let mut ret = Ok(SchemeExpr::SchemeNull); - for expr in body { - //ret = Ok(scheme_meaning(&expr, closure.clone()).unwrap().clone()); - let thing = scheme_meaning(&expr, closure.clone()).unwrap(); - return Ok(thing); - } - return ret; - */ + let ret = &body[0].clone(); + // XXX: Almost Working... + //return scheme_meaning(ret, closure.clone()); return Ok(SchemeExpr::SchemeNull); }, _ => { return Err("non-procedure at head of expression"); }, -- cgit v1.2.3