Fully fledged lambdas, along with efficiency tweaks across the ast
This commit is contained in:
parent
b0bd369c1d
commit
8efa1dbaad
10 changed files with 264 additions and 70 deletions
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
use crate::eval::eval;
|
||||
use crate::segment::{Ctr, Seg};
|
||||
use crate::sym::{Args, SymTable, Symbol, ValueType};
|
||||
use crate::sym::{SymTable, Symbol};
|
||||
|
||||
pub const IF_DOCSTRING: &str =
|
||||
"accepts three bodies, a condition, an unevaluated consequence, and an alternative consequence.
|
||||
|
|
@ -151,15 +151,15 @@ pub fn let_callback(ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
|
|||
|
||||
localsyms.insert(
|
||||
name.clone(),
|
||||
Symbol {
|
||||
name: name.clone(),
|
||||
args: Args::None,
|
||||
conditional_branches: false,
|
||||
docs: "variable used in let form".to_string(),
|
||||
value: ValueType::VarForm(Box::new(*var_val_res.unwrap().clone())),
|
||||
},
|
||||
Symbol::from_ast(
|
||||
name, &"variable used in let form".to_string(),
|
||||
&Seg::from_mono(Box::new(*var_val_res.unwrap().clone())),
|
||||
None),
|
||||
);
|
||||
}
|
||||
} else if let Ctr::None = *var_form.car {
|
||||
// nothing to declare
|
||||
return true;
|
||||
} else {
|
||||
eprintln!("improper declaration of {}: not a list", var_decl);
|
||||
return false;
|
||||
|
|
@ -176,6 +176,7 @@ pub fn let_callback(ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
|
|||
let mut result: Box<Ctr> = Box::new(Ctr::None);
|
||||
if !eval_forms.circuit(&mut |eval_form: &Ctr| -> bool {
|
||||
let res: Result<Box<Ctr>, String>;
|
||||
println!("let: {}", eval_form);
|
||||
if let Ctr::Seg(ref eval_tree) = eval_form {
|
||||
res = eval(&eval_tree, &mut localsyms);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue