Eigenstate: myrddin-dev mailing list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 0/2] Use ? in format specifiers


> As discussed on IRC, I'd like to print/fmt things to some fixed width,
> but I don't know the width at compile time, only at runtime. This allows
> passing '?' as an argument to any format parameter. When processed (in
> sbfmtv), a ? means "Pull the next thing out of ap, turn it into a
> string, and use THAT as the argument". So you can write things like
> 
>     std.put("{w=?}\n", 99, "foo")
>     std.put("{w=?}\n", some_int_var, "bar")
> 
> or even (since everything is string-ified and perhaps unparsed)

As mentioned on IRC as well, not a big fan of this approach.
I was initially thinking that the formatters would get the
'?' as a parameter directly, and then just do something like:


	if eq(widthparam, "?")
		width = vanext()
	else
		width = intparse(widthparam)

	;;
	fmt(val, width)