D newb

Jesse Phillips jessekphillips at gmail.com
Sun Aug 17 20:05:31 PDT 2008


On Sun, 17 Aug 2008 20:09:19 -0400, bearophile wrote:

> 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

http://www.dsource.org/

Most everything there is for D 1.0 many tutorials/examples written before 
its release and only for Phobos (which you are using), but still valid.



More information about the Digitalmars-d mailing list