Date: Tue, 16 May 2023 08:13:54 -0500
On Fri, May 12, 2023 at 9:13 PM Andrew Tomazos <andrewtomazos_at_[hidden]>
wrote:
> Barry,
>
> I actually misread the spec and thought it was UB if arguments were unused
> (so the compiler could catch it statically), so I didn't realize I was
> proposing a breaking change.
>
> May I ask if you understand and support the motivation of the proposal?
> And if so, can you think of a way to change the proposal to avoid the
> breakage while still achieving the goals?
>
No, I don't.
print(x, y, z) in Python just prints x, y, and z (with some
separator/terminator), its formatting is orthogonal. But std::print in C++
takes a format string and does formatting, just like Rust's. If we're going
to do something to make this more convenient to use, we should pursue
string interpolation - which is an overwhelming improvement for user
experience. Even in Python, sure you can write print(x, y) but print(f"{x=}
{y=}") isn't that many more characters and is quite a bit nicer for simple
things. And once you get more complicated, then you need formatting anyway.
In any case, a print function that doesn't take a format string might be
useful, just like a format() that simply concatenates the arguments - which
can be more efficient too in the simple case where all your arguments are
ints and strings. But those would need to use a different name. For
instance, D calls this function writeln().
Lastly, the last example in the paper shows std::println(“#{}:”, 5, 6, 7)
printing the string "#5: 6 7". That's neither C++/Rust approach using the
format string nor Python/etc. printing all the arguments. I definitely
dislike this approach - either one or the other please.
>
> I guess another thought I had would be whether "all that code" is already
> so much. While it seems possible to have prints with unused arguments,
> it's unclear how often that feature is intentionally used (as opposed to
> accidentally used). Maybe it's not too late to change it so that unused
> arguments have to be explicitly marked unused in some fashion (like
> something akin to [[maybe_unused]]) - and if so, the proposal would remain
> viable in the non-marked case.
>
> Notice we could do this for print specifically, and wouldn't have to do it
> for the rest of the std::format applications. I feel like the motivation
> applies specifically to std::print and std::println.
>
> Thanks,
> Andrew.
>
wrote:
> Barry,
>
> I actually misread the spec and thought it was UB if arguments were unused
> (so the compiler could catch it statically), so I didn't realize I was
> proposing a breaking change.
>
> May I ask if you understand and support the motivation of the proposal?
> And if so, can you think of a way to change the proposal to avoid the
> breakage while still achieving the goals?
>
No, I don't.
print(x, y, z) in Python just prints x, y, and z (with some
separator/terminator), its formatting is orthogonal. But std::print in C++
takes a format string and does formatting, just like Rust's. If we're going
to do something to make this more convenient to use, we should pursue
string interpolation - which is an overwhelming improvement for user
experience. Even in Python, sure you can write print(x, y) but print(f"{x=}
{y=}") isn't that many more characters and is quite a bit nicer for simple
things. And once you get more complicated, then you need formatting anyway.
In any case, a print function that doesn't take a format string might be
useful, just like a format() that simply concatenates the arguments - which
can be more efficient too in the simple case where all your arguments are
ints and strings. But those would need to use a different name. For
instance, D calls this function writeln().
Lastly, the last example in the paper shows std::println(“#{}:”, 5, 6, 7)
printing the string "#5: 6 7". That's neither C++/Rust approach using the
format string nor Python/etc. printing all the arguments. I definitely
dislike this approach - either one or the other please.
>
> I guess another thought I had would be whether "all that code" is already
> so much. While it seems possible to have prints with unused arguments,
> it's unclear how often that feature is intentionally used (as opposed to
> accidentally used). Maybe it's not too late to change it so that unused
> arguments have to be explicitly marked unused in some fashion (like
> something akin to [[maybe_unused]]) - and if so, the proposal would remain
> viable in the non-marked case.
>
> Notice we could do this for print specifically, and wouldn't have to do it
> for the rest of the std::format applications. I feel like the motivation
> applies specifically to std::print and std::println.
>
> Thanks,
> Andrew.
>
Received on 2023-05-16 13:14:08