return the other functions of the void main()

Rikki Cattermole via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 9 04:38:26 PDT 2015


On 9/04/2015 11:22 p.m., John Colvin wrote:
> On Thursday, 9 April 2015 at 11:07:05 UTC, Rikki Cattermole wrote:
>> On 9/04/2015 11:03 p.m., Dennis Ritchie wrote:
>>> Hi,
>>> Is it allowed in D similar designs?
>>>
>>> void main() {
>>>     import std.stdio;
>>>     return writeln("Hello, world!");
>>> }
>>
>> Sure when:
>>
>> import std.traits : ReturnType;
>> import std.stdio : writeln;
>>
>> static assert(is(ReturnType!writeln == int));
>
> You might wanna check that :p

No no, its valid D code. After all, as long as the compiler doesn't 
assert, its perfectly valid. I was documenting the usage of return for 
main function's when the return type of it is int.


More information about the Digitalmars-d-learn mailing list