bug? for(int i=0;i<1;) vs while(true)

ddos via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 17 12:47:14 PDT 2015


On Thursday, 17 September 2015 at 19:43:02 UTC, H. S. Teoh wrote:
> On Thu, Sep 17, 2015 at 07:32:13PM +0000, ddos via 
> Digitalmars-d-learn wrote:
>> http://pastebin.com/fknwgjtz
>> 
>> i tried to call fibers in a loop forever, to multiplex some 
>> networking
>> client worker fibers and a listener fiber
>> it seems to work correctly with  for(int i=0;i<1;)
>> 
>> with while(true) i get:
>> 
>> C:\dev\server_client>dub
>> Building server_client ~master configuration "application", 
>> build type
>> debug.
>> Compiling using dmd...
>> source\app.d(72): Warning: statement is not reachable
>> FAIL
>> .dub\build\application-debug-windows-x86-dmd_2068-32A80D3C074EAD350DDE74DB2
>> 61C6BB5\ server_client executable
>> Error executing command run:
>> dmd failed with exit code 1.
>
> Maybe just write:
>
> 	for (;;) {
> 		...
> 	}
>
> instead?  You can read `(;;)` as "ever". :-P
>
> Also, could you post a (possibly reduced) code example that can 
> be compiled?  It's kinda hard to figure out what's wrong when 
> the code in the paste is incomplete.
>
>
> T

yeah i tried for(;;) and it generates the same warning :)
sure, here is the full example, it's not too long anyways
( the example doesn't make much sense tho because socket.accept 
is blocking :P )
http://pastebin.com/9K0wRRD6

ps: pastebin needs D support :-D



More information about the Digitalmars-d-learn mailing list