lua-users home
lua-l archive

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




On 19/01/2023 17:24, Luiz Henrique de Figueiredo wrote:
A couple use cases just off the top of my head: machine generated XML
files with long lines; log files with lots of data on each entry (line);
scientific data files where a single line holds dozens of values in text
form.

There seems to be miscommunication here:
The width in %45s is used to right-justify the string by padding on
the left with spaces.
If the string is longer than the width, it is printed in full.
These statements are valid in both Lua and C.

No, Luiz, I got it. Sorry if I wasn't clear. My point was that I can well imagine use cases where someone do want to right-justify a, say, 150 char string in a 200 char field, maybe as an intermediate step in a more complex procedure.

I concede that for normal interaction with a user that would be highly unusual, but for text not intended as a message to a human it is quite plausible.

In the past I certainly did format strings longer than a couple hundreds chars (to generate LaTeX source) using big fields. I didn't hit that limit just because the algorithm I used didn't need a /single/ 100+ char field specifier with %s, but that was probably just by chance.

-- Lorenzo