// Copyright © 2024-2025 The µcad authors <info@ucad.xyz>
// SPDX-License-Identifier: AGPL-3.0-or-later

//! Builtin print method

use microcad_lang::{eval::*, parameter, resolve::*, value::*};

pub fn print() -> Symbol {
    Symbol::new_builtin_fn(
        "print",
        [parameter!(x)].into_iter(),
        &|_params, args, context| {
            args.iter()
                .try_for_each(|(_, arg)| -> Result<(), EvalError> {
                    context.print(format!("{value}", value = arg.value));
                    Ok(())
                })?;
            Ok(Value::None)
        },
        None,
    )
}
