Added USERLIB with prepend and set.
Added a q shortcut to quote get-doc and set-doc no longer conditionally evaluate args Fixed bug in let, documented potential performance improvements upped default history to 5k lines
This commit is contained in:
parent
a01df6b7b2
commit
1ee9ba55fb
7 changed files with 70 additions and 25 deletions
|
|
@ -205,8 +205,13 @@ pub fn let_callback(ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
|
|||
|
||||
// we need to get any var declared from within the let eval forms
|
||||
// those need to exist in the outside context
|
||||
// TODO: make this more optimal
|
||||
// How can we skip iterations?
|
||||
// implement a counter for number of calls to def
|
||||
// store it inside the SymTable and Symbol
|
||||
// only re-insert into global scope what is most recent
|
||||
for i in localsyms.iter() {
|
||||
if !locals.contains(i.0) && !syms.contains_key(i.0) {
|
||||
if !locals.contains(i.0) {
|
||||
syms.insert(
|
||||
i.0.clone(),
|
||||
i.1.clone(),
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ pub fn eval_callback(ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
|
|||
}
|
||||
},
|
||||
_ => Ok(arguments)
|
||||
}*/
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -195,27 +195,28 @@ pub fn lambda_callback(
|
|||
}
|
||||
|
||||
pub const GETDOC_DOCSTRING: &str = "accepts an unevaluated symbol, returns the doc string.
|
||||
Returns an error if symbol is undefined";
|
||||
Returns an error if symbol is undefined.
|
||||
|
||||
Note: make sure to quote the input like this:
|
||||
(get-doc (quote symbol-name))";
|
||||
|
||||
pub fn getdoc_callback(ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
if ast.len() != 1 {
|
||||
Err("get-doc only takes a single argument".to_string())
|
||||
} else {
|
||||
if let Ctr::Symbol(ref symbol) = *ast.car {
|
||||
if let Some(sym) = syms.get(symbol) {
|
||||
Ok(Ctr::String(sym.docs.clone()))
|
||||
} else {
|
||||
Err("undefined symbol".to_string())
|
||||
}
|
||||
|
||||
if let Ctr::Symbol(ref symbol) = *ast.car {
|
||||
if let Some(sym) = syms.get(symbol) {
|
||||
Ok(Ctr::String(sym.docs.clone()))
|
||||
} else {
|
||||
Err("get-doc should only be called on a symbol".to_string())
|
||||
Err("undefined symbol".to_string())
|
||||
}
|
||||
} else {
|
||||
Err("get-doc should only be called on a symbol".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
pub const SETDOC_DOCSTRING: &str = "accepts a symbol and a doc string.
|
||||
Returns an error if symbol is undefined, otherwise sets the symbols docstring to the argument.";
|
||||
Returns an error if symbol is undefined, otherwise sets the symbols docstring to the argument.
|
||||
|
||||
Note: make sure to quote the input like this:
|
||||
(set-doc (quote symbol-name) my-new-docs)";
|
||||
|
||||
pub fn setdoc_callback(ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
if ast.len() != 2 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue