On 31.07.2010 23:44, Pluto wrote:
This part has always bothered me. Could somebody please explain to me the
rationale behind limiting functions to one usable error code?

if(function())
~~
Inherently if is for testing _condition_ which is true/false. Going futher you'd just reinvent switch statement.
which if perfectly OK for it, here it goes:
    switch(function()){
        case ERR_CODE1:
            // ---
        break;
        case ERR_CODE2:
            // ---
        break;
            // ---
        default:
            // ---
        break;
    }
Honestly, I'd suggest using exceptions instead of error codes.
Usage of error codes scales poorly and itself is very error-prone, also killing the return value of functions just for error code leads to very awkward design.
:Pluto


--
Dmitry Olshansky

Reply via email to