When generic functions use dynamic values

  • Authors:
  • Peter Achten;Artem Alimarine;Rinus Plasmeijer

  • Affiliations:
  • Computing Science Department, University of Nijmegen, Nijmegen, The Netherlands;Computing Science Department, University of Nijmegen, Nijmegen, The Netherlands;Computing Science Department, University of Nijmegen, Nijmegen, The Netherlands

  • Venue:
  • IFL'02 Proceedings of the 14th international conference on Implementation of functional languages
  • Year:
  • 2002

Quantified Score

Hi-index 0.00

Visualization

Abstract

Dynamic types allow strongly typed programs to link in external code at run-time in a type safe way. Generic programming allows programmers to write code schemes that can be specialized at compile-time to arguments of arbitrary type. Both techniques have been investigated and incorporated in the pure functional programming language Clean. Because generic functions work on all types and values, they are the perfect tool when manipulating dynamic values. But generics rely on compile-time specialization, whereas dynamics rely on run-time type checking and linking. This seems to be a fundamental contradiction. In this paper we show that the contradiction does not exist. From any generic function we derive a function that works on dynamics, and that can be parameterized with a dynamic type representation. Programs that use this technique combine the best of both worlds: they have concise universal code that can be applied to any dynamic value regardless of its origin. This technique is important for application domains such as type-safe mobile code and plug-in architectures.