F-Script is mostly latently typed and, as such, could benefit from a type inference system. Among other things, type inference can be used to detect a number of programming errors at compile time (which is nice) without cluttering programs with explicit typing.
Creating such a system for F-Script can draw from techniques already in use with some latently typed languages. Beside, in the case of F-Script, there is a way to improve the efficiency of these techniques to produce a powerful and effective type inference system. The key point is that while F-Script code is largely exempt of explicit typing, most methods invoked from F-Script are actually Objective-C methods for which explicit typing information is often available. This means that we have a massive amount of type information we can feed the type inference system with, making it easier for it to infer new type information in F-Script code and, ultimately, to detect potential programming errors (or to help with automatic optimization, etc.)
This interesting approach is presented by Andrew Weinrich and Ben Liblit, from the University of Wisconsin-Madison, in « Type Inference in Mixed Compiled / Scripting Environments ». In particular, they describe how it is implemented in flint a type checking and static analysis tool for F-Script under development.
Summary:
Programs written in statically-typed languages are commonly extended with scripting engines that manipulate objects in the compiled layer. These scripting environments enhance the capabilities of the program, at the cost of additional errors that would be caught by compile-time type checking. This paper describes a system for using type information from the compiled, statically-typed layer to perform type inference and checking on scripting code. To improve the quality of analysis, idiomatic rules based on common programming patterns are used to supplement the type-inference process. A proof-of-concept of this system is shown inflint, a type-checking tool for the language F-Script.
