Skip to content

Navigation Menu

Sign in
Sign up

Are type checks & dispatches equivalent? #33

fgmccabe started this conversation in Ideas
Discussion options

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.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /