On Friday, 15 March 2024 at 00:11:11 UTC, Andy Valencia wrote:

(varargs & friends)

Which statement leads me to section 77.2 of "Programming in D", and now I am deep into the mechanisms behind what you have very kindly shared. Thank you once more.

As some fruits of my labors here, below is a link to a "fmt" module which does C-style formatting. It supports int/long signed/unsigned, right/left padding and zero padding, plus strings (w. padding). It's memory and type safe; I ended up using unions to tabulate the arguments as I need to access them as an array (rather than walking them--I'm walking the format string instead). It adds 6k to an executable, which means dlang will work out fine for all of my smaller scripting needs in the future.

Calls look like:

auto s = fmt("%d %u - %20s", 123, 456, "Hi, Mom");

https://sources.vsta.org:7100/dlang/file?name=fmt.d&ci=tip

Comments are welcome! I'd post here, but it seems a little long for that?

Andy

Reply via email to