D newb

bearophile bearophileHUGS at lycos.com
Sun Aug 17 17:09:19 PDT 2008


Tim H., others have already answered your main question. Regarding your code:

Add the list of names you want to use, importing just the names you need, avoiding namespace pollution:
import std.c.stdlib: writefln;


>         public int m_int = 0;
This is enough:
        public int m_int;
Because variables are initialized to .init by default (and there's a way to avoid that), and int.init is 0.


> int main(string[] args)

You can use this, because the return value is automatic:
void main()


To print writef/writefln is generally better, because typesafe (but it makes your executable fatter):
writefln(foo %d", f.m_int);

Bye,
bearophile



More information about the Digitalmars-d mailing list