serene-rust-implementation/src/builtins/def.rs

40 lines
1.4 KiB
Rust
Raw Normal View History

2020-09-13 19:29:17 +01:00
/** Serene --- Yet an other Lisp
*
* Copyright (c) 2020 Sameer Rahmani <lxsameer@gnu.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
use crate::compiler::Compiler;
use crate::types::collections::core::Seq;
2020-09-13 19:29:17 +01:00
use crate::types::{ExprResult, List};
pub fn def<'a>(compiler: &'a Compiler, args: List) -> ExprResult<'a> {
2020-09-18 21:52:45 +01:00
// TODO: We need to support docstrings for def
if args.length() != 2 {
// TODO: Raise a meaningful error by including the location
panic!(format!(
"`def` expects 2 parameters, '{}' given.",
args.length()
));
}
2020-09-18 21:52:45 +01:00
//let def_ = &args.first;1
let name = args.first();
let value = args.rest().first();
2020-09-18 21:52:45 +01:00
println!("<<<< {:?} \n {:?}", name, value);
// TODO: make sure that `def_` is a symbol and its name is "def"
2020-09-18 21:52:45 +01:00
Err("Is not completed".to_string())
2020-09-13 19:29:17 +01:00
}