From aa7612926e04a8e3417a209b5f0d0021126b12ae Mon Sep 17 00:00:00 2001 From: John Date: Thu, 11 Jul 2024 04:42:36 -0500 Subject: [PATCH] cl-interpret: Add format builtin Might as well add some new features to play around with until I rip 'em all out --- compiler/cl-interpret/src/builtin.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/compiler/cl-interpret/src/builtin.rs b/compiler/cl-interpret/src/builtin.rs index 114142a..a16f2a3 100644 --- a/compiler/cl-interpret/src/builtin.rs +++ b/compiler/cl-interpret/src/builtin.rs @@ -14,6 +14,16 @@ use std::{ builtins! { const MISC; + /// Unstable variadic format function + pub fn format<_, args> () -> IResult { + use std::fmt::Write; + let mut out = String::new(); + for arg in args { + write!(out, "{arg}").ok(); + } + Ok(ConValue::String(out.into())) + } + /// Unstable variadic print function pub fn print<_, args> () -> IResult { let mut out = stdout().lock();