D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11277 - Bad default main.d (bad hello world example)
Summary: Bad default main.d (bad hello world example)
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: visuald (show other issues)
Version: D2
Hardware: All All
: P2 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-15 17:25 UTC by Jakob Ovrum
Modified: 2015-06-09 05:14 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jakob Ovrum 2013-10-15 17:25:13 UTC
There are a number of small issues with the default-provided main.d file that have been bugging me for a while:

 * The module with `main` contains an explicit module statement, for which I can think of no justification

 * The main function uses an `int` return type without actually needing it, resulting in the boilerplate `return 0;` statement

 * The main function receives the program argument list but doesn't use it. Even if it did use it, it's named `argv` even though there is no `argc` in D; `argv` is still potentially a decent name, but I think `args` is more common, and has no implication of `argc`

I suggest changing it to one of either:
-----
void main()
{
    import std.stdio : writeln;
    writeln("hello, world");
}
-----
Or
-----
import std.stdio;

void main()
{
    writeln("hello, world");
}
-----

The former is probably the most conducive to remaining correct after tweaking.
The latter is probably the most consistently used hello-world example for D2 (e.g. it's used on the front page of wiki.dlang.org).
Comment 1 Rainer Schuetze 2013-10-18 12:22:06 UTC
I'll update according to the second suggestion.
Comment 2 Rainer Schuetze 2013-10-28 23:42:48 UTC
Fixed in v0.3.37rc6 to be found here:

https://github.com/D-Programming-Language/visuald/releases
Comment 3 Rainer Schuetze 2013-11-16 01:03:10 UTC
Templates updated in Visual D 0.3.37