pub fn make_builtins() -> RlispBuiltins {
    builtin_functions!{
        l = lisp;
        "consp" (c) -> { <&ConsCell>::is_type_or_place(c).into() },
        "numberp" (n) -> { RlispNum::is_type_or_place(n).into() },
        "integerp" (n) -> { i32::is_type_or_place(n).into() },
        "floatp" (n) -> { f64::is_type_or_place(n).into() },
        "symbolp" (s) -> { <&Symbol>::is_type_or_place(s).into() },
        "stringp" (s) -> { <&RlispString>::is_type_or_place(s).into() },
        "functionp" (f) -> { <&RlispFunc>::is_type_or_place(f).into() },
        "boolp" (b) -> { bool::is_type_or_place(b).into() },
        "namespacep" (n) -> { <&Namespace>::is_type_or_place(n).into() },
        "placep" (p) -> { Place::is_type(p).into() },
        "cons" (car cdr) -> { l.alloc(ConsCell::new(car, cdr)) },
        "list" (&rest items) -> { items },
        "debug" (obj) -> { println!("{:?}", obj); obj },
        "print" (&rest objects) -> {
            if let Some(cons) = <&ConsCell as MaybeFrom<_>>::maybe_from(objects) {
                let mut count: i32 = 0;
                for obj in cons {
                    print!("{}", obj);
                    count += 1;
                }
                println!();
                count.into()
            } else {
                false.into()
            }
        },
        "eq" (first &rest objects) -> {
            if let Some(cons) = <&ConsCell as MaybeFrom<_>>::maybe_from(objects) {
                #[cfg_attr(feature = "cargo-clippy", allow(explicit_iter_loop))]
                for el in cons.into_iter() {
                    if !(first == el) {
                        return false.into();
                    }
                }
            } else {
                debug_assert!(objects.nilp())
            }
            true.into()
        },
        "wrong-type-error" (wanted found) -> {
            l.alloc(RlispError::wrong_type(wanted, found))
        },
        "wrong-arg-count-error" (found min &optional max) -> {
            let _ = into_type_or_error!(l : found => i32);
            let _ = into_type_or_error!(l : found => i32);
            if bool::from(max) {
                let _ = into_type_or_error!(l : found => i32);
            }
            l.alloc(RlispError::bad_args_count(found, min, max))
        },
        "improper-list-error" () -> {
            l.alloc(RlispError::improper_list())
        },
        "unbound-symbol-error" (sym) -> {
            let _ = into_type_or_error!(l : sym => &'static Symbol);
            l.alloc(RlispError::unbound_symbol(sym))
        },
        "type-designator-error" (designator) -> {
            l.alloc(RlispError::not_a_type(designator))
        },
        "undefined-symbol-error" (sym) -> {
            let _ = into_type_or_error!(l : sym => *const Symbol);
            l.alloc(RlispError::undefined_symbol(sym))
        },
        "index-out-of-bounds-error" (idx reciever) -> {
            l.alloc(RlispError::index_out_of_bounds(idx, reciever))
        },
        "error" (kind &rest info) -> {
            l.alloc(RlispError::custom(kind, info))
        },
        "global-namespace" () -> {
            Object::from(l.symbols[0])
        },
        "type-of" (x) -> {
            l.type_name(x.what_type())
        },
        "car" (cons) -> {
            let cons = into_type_or_error!(l : cons => &mut ConsCell);
            let car: &mut Object = &mut cons.car;
            Object::from(Place::from(car as *mut Object))
        },
        "cdr" (cons) -> {
            let cons = into_type_or_error!(l : cons => &mut ConsCell);
            let cdr: &mut Object = &mut cons.cdr;
            Object::from(Place::from(cdr as *mut Object))
        },
        "nth" (list n) -> {
            let list_cons = into_type_or_error!(l : list => &mut ConsCell);
            let n_int = into_type_or_error!(l : n => i32);
            let mut iter = list_cons.into_iter();
            for _ in 0..n_int {
                if iter.next().is_none() {
                    return l.alloc(RlispError::index_out_of_bounds(n, list));
                }
            }
            if let Some(place) = iter.next() {
                Object::from(place)
            } else {
                l.alloc(RlispError::index_out_of_bounds(n, list))
            }
        },
    }
}
/// Returns the `RlispBuiltinFunctions` used by Rlisp which don't fit
/// better in `math::make_builtins`. Many of these functions relate to
/// type-checking, debugging, and basically anything that doesn't
/// operate exclusively on numbers.
Returns the `RlispBuiltinFunctions` used by Rlisp which don't fit
better in `math::make_builtins`. Many of these functions relate to
type-checking, debugging, and basically anything that doesn't
operate exclusively on numbers.
Returns the ` RlispBuiltinFunctions ` used by Rlisp which don ' t fit better in ` math :: make_builtins ` . Many of these functions relate to type - checking debugging and basically anything that doesn ' t operate exclusively on numbers .
pub fn make_builtins() -> RlispBuiltins {
    builtin_functions!{
        l = lisp;
        "consp" (c) -> { <&ConsCell>::is_type_or_place(c).into() },
        "numberp" (n) -> { RlispNum::is_type_or_place(n).into() },
        "integerp" (n) -> { i32::is_type_or_place(n).into() },
        "floatp" (n) -> { f64::is_type_or_place(n).into() },
        "symbolp" (s) -> { <&Symbol>::is_type_or_place(s).into() },
        "stringp" (s) -> { <&RlispString>::is_type_or_place(s).into() },
        "functionp" (f) -> { <&RlispFunc>::is_type_or_place(f).into() },
        "boolp" (b) -> { bool::is_type_or_place(b).into() },
        "namespacep" (n) -> { <&Namespace>::is_type_or_place(n).into() },
        "placep" (p) -> { Place::is_type(p).into() },
        "cons" (car cdr) -> { l.alloc(ConsCell::new(car, cdr)) },
        "list" (&rest items) -> { items },
        "debug" (obj) -> { println!("{:?}", obj); obj },
        "print" (&rest objects) -> {
            if let Some(cons) = <&ConsCell as MaybeFrom<_>>::maybe_from(objects) {
                let mut count: i32 = 0;
                for obj in cons {
                    print!("{}", obj);
                    count += 1;
                }
                println!();
                count.into()
            } else {
                false.into()
            }
        },
        "eq" (first &rest objects) -> {
            if let Some(cons) = <&ConsCell as MaybeFrom<_>>::maybe_from(objects) {
                #[cfg_attr(feature = "cargo-clippy", allow(explicit_iter_loop))]
                for el in cons.into_iter() {
                    if !(first == el) {
                        return false.into();
                    }
                }
            } else {
                debug_assert!(objects.nilp())
            }
            true.into()
        },
        "wrong-type-error" (wanted found) -> {
            l.alloc(RlispError::wrong_type(wanted, found))
        },
        "wrong-arg-count-error" (found min &optional max) -> {
            let _ = into_type_or_error!(l : found => i32);
            let _ = into_type_or_error!(l : found => i32);
            if bool::from(max) {
                let _ = into_type_or_error!(l : found => i32);
            }
            l.alloc(RlispError::bad_args_count(found, min, max))
        },
        "improper-list-error" () -> {
            l.alloc(RlispError::improper_list())
        },
        "unbound-symbol-error" (sym) -> {
            let _ = into_type_or_error!(l : sym => &'static Symbol);
            l.alloc(RlispError::unbound_symbol(sym))
        },
        "type-designator-error" (designator) -> {
            l.alloc(RlispError::not_a_type(designator))
        },
        "undefined-symbol-error" (sym) -> {
            let _ = into_type_or_error!(l : sym => *const Symbol);
            l.alloc(RlispError::undefined_symbol(sym))
        },
        "index-out-of-bounds-error" (idx reciever) -> {
            l.alloc(RlispError::index_out_of_bounds(idx, reciever))
        },
        "error" (kind &rest info) -> {
            l.alloc(RlispError::custom(kind, info))
        },
        "global-namespace" () -> {
            Object::from(l.symbols[0])
        },
        "type-of" (x) -> {
            l.type_name(x.what_type())
        },
        "car" (cons) -> {
            let cons = into_type_or_error!(l : cons => &mut ConsCell);
            let car: &mut Object = &mut cons.car;
            Object::from(Place::from(car as *mut Object))
        },
        "cdr" (cons) -> {
            let cons = into_type_or_error!(l : cons => &mut ConsCell);
            let cdr: &mut Object = &mut cons.cdr;
            Object::from(Place::from(cdr as *mut Object))
        },
        "nth" (list n) -> {
            let list_cons = into_type_or_error!(l : list => &mut ConsCell);
            let n_int = into_type_or_error!(l : n => i32);
            let mut iter = list_cons.into_iter();
            for _ in 0..n_int {
                if iter.next().is_none() {
                    return l.alloc(RlispError::index_out_of_bounds(n, list));
                }
            }
            if let Some(place) = iter.next() {
                Object::from(place)
            } else {
                l.alloc(RlispError::index_out_of_bounds(n, list))
            }
        },
    }
}
pub fn make_builtins ( ) -> RlispBuiltins { builtin_functions ! { l lisp " " ( c ) { ConsCell is_type_or_place ( c ) into ( ) } " " ( n ) { RlispNum is_type_or_place ( n ) into ( ) } " " ( n ) { i32 is_type_or_place ( n ) into ( ) } " " ( n ) { f64 is_type_or_place ( n ) into ( ) } " " ( s ) { Symbol is_type_or_place ( s ) into ( ) } " " ( s ) { RlispString is_type_or_place ( s ) into ( ) } " " ( f ) { RlispFunc is_type_or_place ( f ) into ( ) } " " ( b ) { bool is_type_or_place ( b ) into ( ) } " " ( n ) { Namespace is_type_or_place ( n ) into ( ) } " " ( p ) { Place is_type ( p ) into ( ) } " " ( car cdr ) { l alloc ( ConsCell new ( car cdr ) ) } " " ( rest items ) { items } " " ( obj ) { println ( " " obj ) obj } " " ( rest objects ) { if let Some ( cons ) ConsCell as MaybeFrom maybe_from ( objects ) { let mut count i32 0 for obj in cons { print ( " " obj ) count 1 } println ( ) count into ( ) } else { false into ( ) } } " " ( first rest objects ) { if let Some ( cons ) ConsCell as MaybeFrom maybe_from ( objects ) { [ cfg_attr ( feature " " allow ( explicit_iter_loop ) ) ] for el in cons into_iter ( ) { if ( first el ) { return false into ( ) } } } else { debug_assert ( objects nilp ( ) ) } true into ( ) } " " ( wanted found ) { l alloc ( RlispError wrong_type ( wanted found ) ) } " " ( found min optional max ) { let into_type_or_error ( l found i32 ) let into_type_or_error ( l found i32 ) if bool from ( max ) { let into_type_or_error ( l found i32 ) } l alloc ( RlispError bad_args_count ( found min max ) ) } " " ( ) { l alloc ( RlispError improper_list ( ) ) } " " ( sym ) { let into_type_or_error ( l sym ' static Symbol ) l alloc ( RlispError unbound_symbol ( sym ) ) } " " ( designator ) { l alloc ( RlispError not_a_type ( designator ) ) } " " ( sym ) { let into_type_or_error ( l sym const Symbol ) l alloc ( RlispError undefined_symbol ( sym ) ) } " " ( idx reciever ) { l alloc ( RlispError index_out_of_bounds ( idx reciever ) ) } " " ( kind rest info ) { l alloc ( RlispError custom ( kind info ) ) } " " ( ) { Object from ( l symbols [ 0 ] ) } " " ( x ) { l type_name ( x what_type ( ) ) } " " ( cons ) { let cons into_type_or_error ( l cons mut ConsCell ) let car mut Object mut cons car Object from ( Place from ( car as mut Object ) ) } " " ( cons ) { let cons into_type_or_error ( l cons mut ConsCell ) let cdr mut Object mut cons cdr Object from ( Place from ( cdr as mut Object ) ) } " " ( list n ) { let list_cons into_type_or_error ( l list mut ConsCell ) let n_int into_type_or_error ( l n i32 ) let mut iter list_cons into_iter ( ) for in 0 n_int { if iter next ( ) is_none ( ) { return l alloc ( RlispError index_out_of_bounds ( n list ) ) } } if let Some ( place ) iter next ( ) { Object from ( place ) } else { l alloc ( RlispError index_out_of_bounds ( n list ) ) } } } }
Returns the `RlispBuiltinFunctions` used by Rlisp which don't fit
better in `math::make_builtins`.
Returns the ` RlispBuiltinFunctions ` used by Rlisp which don ' t fit better in ` math :: make_builtins ` .