Re: [PATCH 0/2] Use ? in format specifiers
[Thread Prev] | [Thread Next]
- Subject: Re: [PATCH 0/2] Use ? in format specifiers
- From: ori@xxxxxxxxxxxxxx
- Reply-to: myrddin-dev@xxxxxxxxxxxxxx
- Date: Sun, 24 Nov 2019 10:15:05 -0800
- To: sgilles@xxxxxxx, myrddin-dev@xxxxxxxxxxxxxx
> 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)
- Prev by Date: [PATCH] Document ? in format specifiers, e.g. {w=?}
- Next by Date: [PATCH v2 0/3] Use ? for width specifiers
- Previous by thread: [PATCH 2/2] Allow formatting arguments from variables
- Next by thread: [PATCH] Document ? in format specifiers, e.g. {w=?}
- Index(es):