diff --git a/main.schala b/main.schala index eed299c..bd6c1d1 100644 --- a/main.schala +++ b/main.schala @@ -1,7 +1,17 @@ +fn add(a, b) + a + b +end + +fn subtract(a, b) + a - b +end fn main() -a = 4 -b = 20 -a + b + first_value = add(20, 20) + second_value = subtract(700, 650) + first_value + second_value end + +main() + diff --git a/src/eval.rs b/src/eval.rs index 8ab3e6e..c322dbd 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -8,7 +8,6 @@ type Reduction = (T, Option); #[derive(Debug)] enum SideEffect { Print(String), - Bundle(Vec), AddBinding(String, Expression), } @@ -128,11 +127,6 @@ impl Evaluator { use self::SideEffect::*; match side_effect { Print(s) => println!("{}", s), - Bundle(l) => { - for side_effect in l { - self.perform_side_effect(side_effect); - } - } AddBinding(var, value) => { self.add_binding(var, value); } @@ -285,19 +279,18 @@ impl Evaluator { self.frames.push(frame); let mut retval = Null; - let mut side_effects = Vec::new(); for expr in function.body.iter() { retval = expr.clone(); while retval.is_reducible() { let r = self.reduce_expr(retval); retval = r.0; if let Some(s) = r.1 { - side_effects.push(s); + self.perform_side_effect(s); } } } self.frames.pop(); - (retval, Some(SideEffect::Bundle(side_effects))) + (retval, None) } }