Re: return the other functions of the void main()

2015-04-09 Thread Dennis Ritchie via Digitalmars-d-learn
On Thursday, 9 April 2015 at 11:07:05 UTC, Rikki Cattermole wrote: Sure when: import std.traits : ReturnType; import std.stdio : writeln; static assert(is(ReturnType!writeln == int)); Thanks. On Thursday, 9 April 2015 at 11:09:43 UTC, John Colvin wrote: Yes, because writeln returns nothing,

Re: return the other functions of the void main()

2015-04-09 Thread John Colvin via Digitalmars-d-learn
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 :

Re: return the other functions of the void main()

2015-04-09 Thread Rikki Cattermole via Digitalmars-d-learn
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

Re: return the other functions of the void main()

2015-04-09 Thread Dennis Ritchie via Digitalmars-d-learn
On Thursday, 9 April 2015 at 17:38:42 UTC, Dennis Ritchie wrote: I think it has something to do with Vindovs :) *Windows

Re: return the other functions of the void main()

2015-04-09 Thread Dennis Ritchie via Digitalmars-d-learn
On Thursday, 9 April 2015 at 17:08:44 UTC, Dennis Ritchie wrote: Operates a code normally, but still gives the error: http://ideone.com/kDHMk5 I think it has something to do with Vindovs :) - http://dpaste.dzfl.pl/4c5bb9dd0ffa

Re: return the other functions of the void main()

2015-04-09 Thread via Digitalmars-d-learn
On Thursday, 9 April 2015 at 11:09:43 UTC, John Colvin wrote: On Thursday, 9 April 2015 at 11:04:00 UTC, Dennis Ritchie wrote: Hi, Is it allowed in D similar designs? void main() { import std.stdio; return writeln(Hello, world!); } Yes, because writeln returns nothing, but

Re: return the other functions of the void main()

2015-04-09 Thread Dennis Ritchie via Digitalmars-d-learn
On Thursday, 9 April 2015 at 11:04:00 UTC, Dennis Ritchie wrote: Hi, Is it allowed in D similar designs? void main() { import std.stdio; return writeln(Hello, world!); } It seems that you can not do so because writeln() something back, which leads to RUNTIME_ERROR in DMD

Re: return the other functions of the void main()

2015-04-09 Thread Jack Applegame via Digitalmars-d-learn
I quite often have to write similar designs: - import std.stdio; void main() { auto a = [ 1, 2, 3, 4, 5 ]; foreach (e; a) { if (e == 4) { writeln(Yes); return; } }

Re: return the other functions of the void main()

2015-04-09 Thread John Colvin via Digitalmars-d-learn
On Thursday, 9 April 2015 at 16:02:01 UTC, Dennis Ritchie wrote: On Thursday, 9 April 2015 at 11:04:00 UTC, Dennis Ritchie wrote: Hi, Is it allowed in D similar designs? void main() { import std.stdio; return writeln(Hello, world!); } It seems that you can not do so because

Re: return the other functions of the void main()

2015-04-09 Thread John Colvin via Digitalmars-d-learn
On Thursday, 9 April 2015 at 11:04:00 UTC, Dennis Ritchie wrote: Hi, Is it allowed in D similar designs? void main() { import std.stdio; return writeln(Hello, world!); } Yes, because writeln returns nothing, but why would you do that? Just put the return on the next line,

Re: return the other functions of the void main()

2015-04-09 Thread Rikki Cattermole via Digitalmars-d-learn
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));

Re: return the other functions of the void main()

2015-04-09 Thread bearophile via Digitalmars-d-learn
Jack Applegame: writeln(a.find(4).empty ? No : Yes); canFind? Bye, bearophile

Re: return the other functions of the void main()

2015-04-09 Thread Dennis Ritchie via Digitalmars-d-learn
On Thursday, 9 April 2015 at 12:57:26 UTC, Jack Applegame wrote: I quite often have to write similar designs: - import std.stdio; void main() { auto a = [ 1, 2, 3, 4, 5 ]; foreach (e; a) { if (e == 4) { writeln(Yes);

Re: return the other functions of the void main()

2015-04-09 Thread Dennis Ritchie via Digitalmars-d-learn
On Thursday, 9 April 2015 at 16:55:00 UTC, John Colvin wrote: Try running your code somewhere where you can actually see the output properly. RUNTIME_ERROR isn't something I recognise from D. Operates a code normally, but still gives the error: http://ideone.com/kDHMk5

Re: return the other functions of the void main()

2015-04-09 Thread John Colvin via Digitalmars-d-learn
On Thursday, 9 April 2015 at 11:38:26 UTC, Rikki Cattermole wrote: 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