refactor type_function
Merge pull request #1567 from WalterBright/b39

refactor type_function