Progopedia - encyclopedia of programming languages

JMRyan nospam at nospam.com
Tue Nov 24 11:05:20 PST 2009


Anders F Björklund <afb at 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.



More information about the Digitalmars-d-announce mailing list