Logo

Programming-Idioms

History of Idiom 50 > diff from v21 to v22

Edit summary for version 22 by :

Version 21

2015-10-25, 01:53:32

Version 22

2015-10-29, 14:05:14

Idiom #50 Make an infinite loop

Write a loop which has no end clause.

Idiom #50 Make an infinite loop

Write a loop which has no end clause.

Code
Control.Monad.forever (getLine >>= putStrLn)
Code
Control.Monad.forever (getLine >>= putStrLn)
Code
for(;;){
	// Do something
}
Code
for(;;){
	// Do something
}
Comments bubble
You may remove the curly braces if the block is only 1 instruction.
Comments bubble
You may remove the curly braces if the block is only 1 instruction.
Imports
#define forever while(1)
Imports
#define forever while(1)
Code
forever {
	// Do something
}
Code
forever {
	// Do something
}
Comments bubble
forever can be defined as a preprocessor constant to improve readability.

You may remove the curly braces if the block is only 1 instruction.
Comments bubble
forever can be defined as a preprocessor constant to improve readability.

You may remove the curly braces if the block is only 1 instruction.