Over the last two decades practically all object-oriented programming languages have introduced features that are well-known from functional programming languages. But many features that were introduced were fragmentary. In Java-TX we address the latter features and propose a completion. Java-TX (i.e. Type eXtended) is a language based on Java. The predominant new features are global type inference and real function types for lambda expressions. Global type inference means that all type annotations can be omitted, and the compiler infers them without losing the static type property. We introduce the function types in a similar fashion as in Scala but additionally integrated them into the Java target-typing as proposed in the so-called strawman approach. In this paper, we provide an integrated presentation of all Java-TX features. The focus is therby on the automatic inference of type parameters for classes and their methods, and on the heterogeneous translation of function types, which permits the preservation of the argument and return types in bytecode.
翻译:在过去的二十年中,几乎所有面向对象编程语言都引入了函数式编程语言中广为人知的特性。然而,许多已引入的特性是零散的。在Java-TX中,我们针对这些零散特性提出了一种完善方案。Java-TX(即类型扩展)是一种基于Java的语言。其主要的新特性包括全局类型推断和lambda表达式的真实函数类型。全局类型推断意味着所有类型注解都可以省略,编译器在推断时不会丢失静态类型属性。我们以类似于Scala的方式引入了函数类型,但进一步将其集成到Java的目标类型系统中,如所谓的"strawman"方案所提议。本文对Java-TX的所有特性进行了综合阐述,重点在于类及其方法的类型参数自动推断,以及函数类型的异构翻译——这种翻译方式使得字节码中能够保留参数和返回类型。