A compiler may not be able to optimize out type checks completely, but it could generate code which tests whether an object is of expected type, performs operations optimized for that type if so, and otherwise uses code that can handle arbitrary types. Not as big a win as eliminating the type checks, but still pretty big nonetheless.
2
u/flatfinger Jun 28 '21
A compiler may not be able to optimize out type checks completely, but it could generate code which tests whether an object is of expected type, performs operations optimized for that type if so, and otherwise uses code that can handle arbitrary types. Not as big a win as eliminating the type checks, but still pretty big nonetheless.