D newb

bearophile bearophileHUGS at lycos.com
Mon Aug 18 03:34:30 PDT 2008


Steven Schveighoffer:

> The way you originally had it.  I think bearophile was saying that in your 
> particular example, you don't need to use it, because you never return 
> anything but zero (EXIT_SUCCESS).

This too works, even if it looks a bit strange:

void main() {
  return 1
}


> Most of the time, you can just use %s:
> writef("%s, %s is an int, %s is a float, %s is a long", "hi", 5, 4.3, 
> 1000000000000);

In some situations you can also just avoid using formatting:
writef("The result is ", r0, " after ", n, " iterations.");

But you have to be careful that the first string doesn't contain % for other purposes. To avoid that D 2.x has write/writeln (or you can use my better put/putr functions).

(I think I now know enough of D that I may be able to start writing a "D best practices" web page).

Bye,
bearophile



More information about the Digitalmars-d mailing list