Abstract
Scala is a well-established multi-paradigm programming language known for itsterseness that includes advanced type inference features. Unfortunately thistype inferring algorithm does not support typing of recursive functions.This is both against the original design philosophies of Scala and puts anunnecessary burden on the programmer. In this paper we propose a method tocompute the return types for simple recursive functions in Scala. We makea heuristic assumption on the return type based on the non-recursive executionbranches and provide a proof of this method's correctness. The algorithm does not havea significant effect on the compilation speed. We implemented our method asan extension prototype in the Scala compiler and used itto successfully test our method on various examples. The compiler extensionprototype is available for further tests.
Subject
Computer Vision and Pattern Recognition,Software,Computer Science (miscellaneous),Electrical and Electronic Engineering,Information Systems and Management,Management Science and Operations Research,Theoretical Computer Science
Reference16 articles.
1. Soft typing with conditional types
2. Armstrong, Joe, Virding, Robert, Wikström, Claes, and Williams, Mike. Concurrent programming in ERLANG. Prentice Hall, 1993.
3. Coplien, James O. Multi-paradigm design for C++. Addison-Wesley Longman Publishing Co., Inc., 1998.
4. A Core Calculus for Scala Type Checking
5. The principle type-scheme of an object in combinatory logic