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.
Scala is an emerging programming language that supports multiple programming paradigms. It has been designed to support high levels of expressiveness and to allow writing concise code. To achieve this, it supports many features, including but not limited to macros, DSLs as well as implicit type conversions and implicit argument lists to functions. Due to the wide range of language features and the advanced static type system, the Scala compiler possesses a non-trivial implementation. We have analyzed the performance characteristics of the compiler and have found that the major part of compilation time is spent on typing syntax trees. This includes implicit resolution, thus we have focused our efforts on investigating this specific language feature. We have analyzed how typical usage patterns that involve implicit resolution affect compilation times. Based on this analysis we have managed to assemble a list of recommendations for programming style and code management that allow programmers to leverage implicits to their full potential, but lead to drastically reduced compilation times.
scite is a Brooklyn-based organization that helps researchers better discover and understand research articles through Smart Citations–citations that display the context of the citation and describe whether the article provides supporting or contrasting evidence. scite is used by students and researchers from around the world and is funded in part by the National Science Foundation and the National Institute on Drug Abuse of the National Institutes of Health.