What type of `print` formatting do you prefer?

rempas rempas at tutanota.com
Wed Dec 22 07:53:58 UTC 2021


On Wednesday, 22 December 2021 at 01:40:02 UTC, Paul Backus wrote:
>
> One of the big advantages of C's format-string syntax is that 
> its conventions are largely shared across programming 
> languages. For example, if you know what `%d` means in C, then 
> you also know what it means in Java, Go, D, and any other 
> language that uses C-style format strings.
>
I understand what you are saying but my problem with this thought 
is that we should not consider something like that because what 
I'm always saying is that we should evolve and learn new things 
rather that sticking to the old things. Of course if the old 
things are better, we should stick on them and if we are going to 
evolve on something, we must make it better on EVERYTHING (well 
it's not possible to make something better in 100% of the areas 
but you get my point). So I don't like the idea of using the old 
way of doing it because people know about it. If we make 
something better (and I think the "{}" syntax is better as I 
explained why) then I think people will stick and learn it (and 
love it :P). For that reason, I think we should invest on 
something new that may be the standard one day. Don't forget that 
the curly bracket syntax is not new anyway, a lot of languages 
already support it. With this conclusion,

> If you are planning on designing a new `{}`-style format-string 
> syntax, I would strongly recommend aiming for consistency with 
> other languages like Python, Rust, and C# that use `{}` for 
> string formatting. For example: all of those languages use 
> `{0}` to insert the first parameter, `{1}` to insert the 
> second, and so forth, so your new library should do the same.
>
Like I said in previous replays, this will be useful in some 
cases so I will implement it but only as optional. This way a lot 
of people that don't want to use it (including myself) will not 
have to use it and people that want to use it will be able to use 
it. This is the best way having both sides happy (which is 
something I really do care) and it's one of the very few things 
that we can keep 100% of the users happy so I'm very confident 
with this approach.


More information about the Digitalmars-d mailing list