2017-05-26 21:03 GMT+02:00 Aaron B. <email@example.com>:On Fri, 26 May 2017 17:32:49 +0200
François Perrad <firstname.lastname@example.org> wrote:
> printf("x = %d y = %d", 10, 20); -- C
> string.format("x = %d y = %d", 10, 20) -- Lua 5.0
> ("x = %d y = %d"):format(10, 20) -- Lua 5.1
> cout << "x = " << 10 << " y = " << 20; -- C++
> string.buffer():put'x = ':put(10):put' y = ':put(20) -- proposal
The C/Lua 5.0/Lua 5.1 way looks a lot more readable to me, compared to
the C++/proposal method.
The reason being, with the format string, in a glance I can see what
the output will look like. With the stream, I have to put all the pieces
together in my mind first.
Aaron B. <email@example.com>
Well, at this time, the feedbacks seem clear : everybody is happy with minilanguages.As seasoned C developer, I know (and I daily use) the `sprintf` formating, so I am biased.But the pack/unpack minilanguage is not obviously readable.And same thing with `os.date` which uses the C `strftime` minilanguage.An implementation based on a minilanguage doesn't allow user extension, for example, you cannot add a "%Q" option to `string.format` in pure Lua.François