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

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 17 12:39:14 PDT 2015


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

-- 
Любишь кататься - люби и саночки возить. 


More information about the Digitalmars-d-learn mailing list