
Beman Dawes wrote:
"Peter Dimov" <pdimov@mmltd.net> wrote in message news:005f01c5547e$3e22aec0$6401a8c0@pdimov2...
You don't need a name because the user will never test for this category. if( status() & other_flag ) { // OK, so what do I do here? }
The other categories have expectations attached, so testing for them makes sense.
What you might do in the code above is report the fact that an "other" has been discovered, or execute a fallback procedure, or whatever.
A fallback only makes sense if a test fails, not when it succeeds. int r = status(); if( r & directory_flag ) { // directory } else if( r & file_flag ) { // implementation defined, but in general file-like } else { // fallback } Note that the code is resilient to future changes introducing other categories. if( r & other_flag ) { // fallback? } When the "other" category is split to "device" and "other other", the meaning of the above code changes. It no longer falls back when it encounters a device, but it did before. Explicit tests for "other" or "unknown" are evil and will not pass a sensible code review anyway.