Think at a level of abstraction higher than just literal statements. An if statement is representative of a class of conditional statements. As is a switch. A switch is just a DSL for a sequence of if statements. I'm so glad you know they compile to jump tables but you're going the wrong direction in level of abstraction.
Yes, I have problems with people using them because they write shitty state-filled code that I have to debug when I could be doing something more enjoyable.
Let's make things more complicated...
Code:
//there could be more than one event during one tick, that's why we need:
//indexBegin is the first event in the timeline of events since the EA got attached
//indexEnd is the last event in the timeline
void onError(EventType &e, EventIndex& indexBegin, EventIndex Index& indexEnd)
{
print(e.name(indexBegin)); // print first event in timeline
print(e.name(indexEnd)); // print Last event in timeline
}
//-----
Linkers::X(EventType &e, Index& indexBegin, Index& indexEnd)
{
switch (e)
{
case error: onError(e, indexBegin, indexEnd); break;
// approaching nearest round number, print it
case round_number: print(e.roundNumber());
}
}
Last edited: