November 24, 2009
BCS <none@anon.com> wrote in news:a6268ffd5508cc3a873791ae4c@news.digitalmars.com:

>> I'm not sure which is right, but I don't think they can both be right as  "x is y" is more like "x == y" in C++ than "*x == *y". I might be wrong  here; as I am a bit confused about this.
> 
> I think you are correct "is" in D does to pointers what "==" does in C++.

Fixed.

PS.  I have posted here in the past as JMNorris, but resistered at Progopedia as JMRyan.  So, except for one mistake, I've posted in this thread as JMRyan.  Sorry for the confusing sock-puppetry--nothing nefarious is intended.
November 24, 2009
Andrei Alexandrescu wrote:

>> Okay.  I added a D entry.  It should be checked for accruacy.  I haven't added programming examples yet; I'll add at least the three example types shown on at http://progopedia.com/ (Hello world, Factorial, Fibonacci).
> 
> Excellent, thanks JMNorris! This is exactly the kind of publicity D needs now.

Strangely, the Hello World program is not the one that is in D:

import std.c.stdio;

int main(char[][] args)
{
    printf("hello world\n");
    printf("args.length = %d\n", args.length);
    for (int i = 0; i < args.length; i++)
        printf("args[%d] = '%s'\n", i, cast(char *)args[i]);
    return 0;
}

But instead some half-way variant of the updated version for D:

import std.stdio;

void main(string[] args)
{
    writefln("hello world");
    foreach(string arg; args)
        writefln("%s", arg);
}

Otherwise I think that is a good example of the differences,
even though it doesn't cover puts/writeln or handle errors...

And of course it makes a couple of assumptions such as the
terminal being in UTF-8. But I guess that's a Windows issue ?

--anders


PS. I think I call that program "echo" rather than "hello".
    Even had a first version "nothing" that prints nothing:
    http://gdcmac.sourceforge.net/GettingStarted.pdf (Mac)
    http://gdcwin.sourceforge.net/GettingStarted.pdf (Win)
November 24, 2009
Michael Mittner wrote:
>> A K&R type book for D, “The D Programming Language”, written by Andrei 
> Alexandrescu and published by Addison-Wesley Professional is scheduled for publication in May 1010.
> 
> D has come a long way!

It time travelled to the past!
November 24, 2009
JMNorris wrote:
> Walter Bright <newshound1@digitalmars.com> wrote in news:heetio$be1$1
> @digitalmars.com:
> 
>> Does someone want to write a D entry?
>>
>> http://progopedia.com/
> 
> Okay.  I added a D entry.  It should be checked for accruacy.  I haven't added programming examples yet; I'll add at least the three example types shown on at http://progopedia.com/ (Hello world, Factorial, Fibonacci).

Cool.

I think the "For each value in a numeric range, 1 increment" can be replaced by:

  foreach(i; 0 .. limit) statement

and the other with

  foreach_reverse(i; 0 .. limit) statement

but these only work for D2 and probably some people here won't like the foreach_reverse version.
November 24, 2009
Ary Borenszweig <ary@esperanto.org.ar> wrote in news:heg99k$6ri$1@digitalmars.com:


> I think the "For each value in a numeric range, 1 increment" can be replaced by:
> 
>    foreach(i; 0 .. limit) statement
> 
> and the other with
> 
>    foreach_reverse(i; 0 .. limit) statement
> 
> but these only work for D2 and probably some people here won't like the foreach_reverse version.

Thanks for the suggestion.

To accommodate this, I would need to divide D1 and D2 into separate languages.  For example, Progopedia would require that K&R C, C89, C85, and C99 be listed as separate languages.  Versions in Progopedia are versions of an implementation.  Thus, e.g., GCC 4.4.2 and GCC 4.4.1 would be separate versions.  Indeead the GCC listing is (in theory) out of date at 4.2.4.  It makes sense in an absurd sort of way.  None of the other languages on Progopedia go in for this level of detail.  Indeead the GCC listing is (in theory) out of date at 4.2.4.


November 24, 2009
Anders F Björklund <afb@algonet.se> wrote in news:heg2ls$2j6v$1 @digitalmars.com:

Thank you for your suggestions below.

> Strangely, the Hello World program is not the one that is in D:

I don't understand.  You appear to be referring a connonical or otherwise previously publish version fo D.  Or perhaps I misunderstood you.

> But instead some half-way variant of the updated version for D:
> 
> import std.stdio;
> 
> void main(string[] args)
> {
>      writefln("hello world");
>      foreach(string arg; args)
>          writefln("%s", arg);
> }

Progopedia specifies that the program should write "Hello, World!" to the display (prsumably the terminal).  Echoing additional command line arguments is out of spec.

Do you have a full-way variant for me to look at?  Is what you have in mind for a full-way variant the suggestions below?  Or do you have something else in mind?

> 
> Otherwise I think that is a good example of the differences, even though it doesn't cover puts/writeln or handle errors...

I didn't use writeln() because it is not available in D1.  I added a note about that.  Looking at other examples on Progopedia, it seems that puts() is beyond the scope of the article.

It sort of handles errors:  writefln throws.  I don't trap thrown errors,
but that seems okay for this example.

> And of course it makes a couple of assumptions such as the terminal being in UTF-8. But I guess that's a Windows issue ?

Actually, it makes a much safer assumption, namely that, whatever character set the terminal uses, it' ASCII compatible.  I suppose it might have some trouble with an EBCDIC terminal.  I suppose that's a good thing. :-)  More troubling, I'm assuming the terminal is not UTF-16 or UTF-32.  Worrying about this seems to be beyond the scope of the Progopedia article.

Thanks again for your suggestions.

November 24, 2009
JMRyan wrote:

> I don't understand.  You appear to be referring a connonical or otherwise previously publish version fo D.  Or perhaps I misunderstood you.

I meant the canonical samples/d/hello.d as in the DMD distributions.

> I didn't use writeln() because it is not available in D1.  I added a note about that.  Looking at other examples on Progopedia, it seems that puts() is beyond the scope of the article.

Probably right. Same goes for adding Tango, quickly gets complicated.

>> And of course it makes a couple of assumptions such as the
>> terminal being in UTF-8. But I guess that's a Windows issue ?
> 
> Actually, it makes a much safer assumption, namely that, whatever character set the terminal uses, it' ASCII compatible.  I suppose it might have some trouble with an EBCDIC terminal.  I suppose that's a good thing. :-)  More troubling, I'm assuming the terminal is not UTF-16 or UTF-32.  Worrying about this seems to be beyond the scope of the Progopedia article.

If one is echoing parameters back (which normal "hello" is not),
then there was a D problem with terminals that are not UTF-8:

# such as ISO-8859-1:
$ ./echo hallå världen
./echo
Error: 4invalid UTF-8 sequence

But it doesn't apply to this Progopedia "hello" but only to the
D "hello", so never mind me muddying up the waters in this thread.

--anders
1 2
Next ›   Last »