Clearly Label D1/D2/Tango/Phobos

Paul phshaffer at gmail.com
Wed Apr 18 15:34:09 PDT 2012


On Wednesday, 18 April 2012 at 14:15:08 UTC, Somedude wrote:
> Le 18/04/2012 14:34, Paul a écrit :
>> I bought the book and am trying to patiently learn this 
>> language.  I
>> follow various tutorials here and around the web that 
>> frequently won't
>> compile.  I suspect it has something to do with 
>> D1/D2/Phobos/Tango and
>> not just really poor unvetted tutorials.  It would really be 
>> helpful if
>> those providing references, code snippets, tutorials, etc 
>> clearly
>> identify the context (i.e D1/D2/Phobos/Tango).  I just think 
>> it would
>> help accelerate the spread and acceptance of this language if 
>> more of
>> the code worked as listed.
>> 
>> If people are out cruising the web and download a fresh copy 
>> of D with
>> excitement (about a cleaned-up, updated c-type systems 
>> language) and
>> then the first several things don't compile w/o errors, 
>> they're going to
>> move on.
>> 
>> Thanks so much to all who provide references, tutorials, etc!  
>> It is
>> great service in helping others learn.  I hope this is seen as
>> constructive criticism for that is what it is.
>
>
> Hi !
>
> It's simple: use D2, and forget about Tango.
> D1 is deprecated and its maintainance will be stopped by the 
> end of the
> year. Noone should be starting with D1 now.
>
> You can start here:
> http://prowiki.org/wiki4d/wiki.cgi?D__Tutorial
>
> I cleaned up this page a little bit, I hope this helps.

I tried one "file open" example from this site and one from 
another site and neither compiled w/o errors.  I thought perhaps 
I had copied some code that might have been related to a specific 
version of D.  I was just commenting that for people who are 
supplying exmaples/tutorials it would help if they specified more 
clearly what version/genre of D their code sample works with.  I 
have no opinion on the Phobos/Tango or deprecated 
features/version stuff.  I just think it would help the 
acceptance of the language if stuff compiled as listed.

As for the example from this site under std.stdio; it should 
compile.  It's a simple program.  This is the mother site.

A member helped me realize that it needs "import std.stdio;"


// test.d
void main(string args[])
{
     auto f = File("test.txt", "w"); // open for writing
     f.write("Hello");
     if (args.length > 1)
     {
         auto g = f; // now g and f write to the same file
                     // internal reference count is 2
         g.write(", ", args[1]);
         // g exits scope, reference count decreases to 1
     }
     f.writeln("!");
     // f exits scope, reference count falls to zero,
     // underlying FILE* is closed.
}



More information about the Digitalmars-d-learn mailing list