Case .. else raise, again
Yesterday I used a really bad example which got most of my readers thinking about how most of the code could be optimized away. As that was not the idea behing my post, I decided to give a better example. This one is straight from the production code: case mafWorkerOwner.PostToThread(MSG_AF_SCHEDULE_VIDEO, clonedBuffer) of Am I making more sense now? |
4 Comments:
It *was* clear first time around, even for would-be smart arses (or at least, should have been)...
It was clear to me too, but maybe because I do exactly what you do.
How about write a function instead of putting your raise directly there?
procedure UNHANDLED_CASE(const Msg: string);
begin
{$IFOPT C+} //debugger mode
raise ....
{$ENDIF}
end;
function UNHANDLED_CASE(const Msg: string; ExpectedValue: Boolean): Boolean;
begin
...
end;
function UNHANDLED_CASE(const Msg: string; ExpectedValue: Integer): Boolean;
begin
...
end;
And so on
If you like it that way, why not.
Post a Comment
Links to this post:
Create a Link
<< Home