【24h】

Dynamic Inference of Static Types for Ruby

机译:Ruby的静态类型的动态推理

获取原文

摘要

There have been several efforts to bring static type inference to object-oriented dynamic languages such as Ruby, Python, and Perl. In our experience, however, such type inference systems are extremely difficult to develop, because dynamic languages are typically complex, poorly specified, and include features, such as eval and reflection, that are hard to analyze. In this paper, we introduce constraint-based dynamic type inference, a technique that infers static types based on dynamic program executions. In our approach, we wrap each run-time value to associate it with a type variable, and the wrapper generates constraints on this type variable when the wrapped value is used. This technique avoids many of the often overly conservative approximations of static tools, as constraints are generated based on how values are used during actual program runs. Using wrappers is also easy to implement, since we need only write a constraint resolution algorithm and a transformation to introduce the wrappers. The best part is that we can eat our cake, too: our algorithm will infer sound types as long as it observes every path through each method body-note that the number of such paths may be dramatically smaller than the number of paths through the program as a whole. We have developed Rubydust. an implementation of our algorithm for Ruby. Rubydust takes advantage of Ruby's dynamic features to implement wrappers as a language library. We applied Rubydust to a number of small programs and found it to be both easy to use and useful: Rubydust discovered 1 real type error, and all other inferred types were correct and readable.
机译:有几项努力将静态类型推断为面向对象的动态语言(如Ruby,Python和Perl)带来。然而,在我们的经验中,这种类型的推理系统非常困难发展,因为动态语言通常是复杂的,指定不良,并且包括难以分析的特征,例如eval和反射,这很难分析。在本文中,我们引入了基于约束的动态类型推断,这是一种基于动态程序执行的静态类型的技术。在我们的方法中,我们将每个运行时值包装以将其与类型变量相关联,并且在使用包装值时,包装器会在此类型变量上生成约束。该技术避免了静态工具的许多经常过于保守的近似值,因为基于在实际程序运行期间使用值的基础产生约束。使用包装器也很容易实现,因为我们只需要编写约束解析算法和转换以介绍包装器。最好的部分是我们也可以吃蛋糕:我们的算法将推断出声类型,只要它通过每个方法正文观察每个路径 - 请注意,这种路径的数量可能会大于通过程序的路径数量小。整个。我们开发了rubydust。我们对Ruby算法的实现。 RubyDust利用Ruby的动态功能来实现包装作为语言库。我们将RubyDust应用于许多小程序,发现它既易于使用,有用:RubyDust发现了1个真实类型的误差,所有其他推断类型都是正确且可读的。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号