-
Notifications
You must be signed in to change notification settings - Fork 19
It is possible to imagine that dispatching on an event is equivalent to a type check. In particular, if there is only one way of responding to an event, dispatching on the event is similar to a type cast. Thus, if is is possible to prove at compile time that the cast cannot fail, then the dispatch is unnecessary.
Moreover, if there is more than one way of responding to an event, then multiple types (of the different events) must be discriminated and again, dispatching might be considered to be a form of multi-way cast.
There may be senses in which dispatch is not 'reducible' to casting: the cost of performing a multi-way branch may be lower than multiple cast instructions -- especially if there is any form of subtyping involved.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment