Adam D. Ruppe:
> I do a lot. The way I do it is the arguments are made
> available to the format, but it doesn't always need them
> at runtime.
>
> string f = showNames ? "%1$s\t%2$d" : "%2$d";
> writefln(f, name, number);
>
> Though I don't literally use writefln for most
> my code the same ide
On 11/02/2011 09:00 PM, Adam D. Ruppe wrote:
bearophile:
But how many times do you want to ignore some of the
arguments listed?
I do a lot. The way I do it is the arguments are made
available to the format, but it doesn't always need them
at runtime.
string f = showNames ? "%1$s\t%2$d" : "%2$
bearophile:
> But how many times do you want to ignore some of the
> arguments listed?
I do a lot. The way I do it is the arguments are made
available to the format, but it doesn't always need them
at runtime.
string f = showNames ? "%1$s\t%2$d" : "%2$d";
writefln(f, name, number);
Though I d
Andrej Mitrovic:
> Personally I like using this for a sort of on/off switch:
> bool val;
> // ..
> val ^= 1;
>
> Maybe that's just stupid but I'm kind of used to it, lol. :p
I use this, I think it's more explicit (but you have to state the variable name
two times):
val = !val;
Bye,
bearophile
Adam D. Ruppe:
> bearophile wrote:
> > Currently this is not caught by D, it prints "12":
> > import std.stdio;
> > void main() {
> >writefln("%d%d", 1, 2, 3);
> > }
>
> That's not really an error. You might change out the format
> string at runtime based on user preferences, perhaps for
> in
Personally I like using this for a sort of on/off switch:
bool val;
// ..
val ^= 1;
Maybe that's just stupid but I'm kind of used to it, lol. :p
bearophile wrote:
> Currently this is not caught by D, it prints "12":
> import std.stdio;
> void main() {
>writefln("%d%d", 1, 2, 3);
> }
That's not really an error. You might change out the format
string at runtime based on user preferences, perhaps for
internationalization, or other reasons
The now usual article that advertises the PVS-Studio tool that shows plenty of
(depressing) bugs found in already debugged source code of widely used C/C++
open source projects:
http://software.intel.com/en-us/articles/90-errors-in-open-source-projects/
There is a Reddit discussion too, but I f