R
Roedy Green
I would like it if you could write:
if ( birthYear == 610
|| birthYear == 1791
|| birthYear == 1851
|| birthYear == 1872 ) )
as
if ( birthYear in { 610, 1791, 1851, 1872} )
or
if ( birthYear in SPECIAL_YEARS )
The compiler could be clever. If you said something like this:
if ( i in { 1 , 2 ,3 ,4, 6, 7, 8, 9 } )
It could generate code as
if ( 1 <= i && i <= 9 && i != 5 )
Or it could create a boolean array, or even a map for big lists.
--
Roedy Green Canadian Mind Products
http://mindprod.com
Refactor early. If you procrastinate, you will have
even more code to adjust based on the faulty design.
..
if ( birthYear == 610
|| birthYear == 1791
|| birthYear == 1851
|| birthYear == 1872 ) )
as
if ( birthYear in { 610, 1791, 1851, 1872} )
or
if ( birthYear in SPECIAL_YEARS )
The compiler could be clever. If you said something like this:
if ( i in { 1 , 2 ,3 ,4, 6, 7, 8, 9 } )
It could generate code as
if ( 1 <= i && i <= 9 && i != 5 )
Or it could create a boolean array, or even a map for big lists.
--
Roedy Green Canadian Mind Products
http://mindprod.com
Refactor early. If you procrastinate, you will have
even more code to adjust based on the faulty design.
..