Monotonic References for Gradual Typing
نویسندگان
چکیده
We describe an alternative approach to handling mutable references (aka. pointers) within a gradually typed language that has different efficiency characteristics than the prior approach of Herman et al. [2010]. In particular, we hope to reduce the costs of reading and writing through references in statically typed regions of code. We would like the costs to be the same as they would in a statically typed language, that is, simply the cost of a load or store instruction (for primitive data types). This reduction in cost is especially important for programmers who would like to use gradual typing to facilitate transitioning from a dynamically-typed prototype of an algorithm to a statically-typed, high-performance implementation. The programmers we have in mind are scientists and engineers who currently prototype in Matlab and then manually translate their algorithms into Fortran. While our alternative approach succeeds in improving the efficiency of dereference and updates in statically typed code, it does come with some limitations. The approach requires all heap-allocated values to be tagged with their runtime type, which may be an added cost in space (though many languages require such tags for other reasons). In addition, our approach requires all values to be of a uniform size, which is true for many languages (most functional and object-oriented languages) but not true for some (the C family of languages). Finally, our approach is more restrictive than prior ones in that certain usage patterns are not allowed, triggering runtime exceptions, for which we give examples later in this introduction. The source of inefficiency in the prior approach of Herman et al. [2010], which we refer to as “guarded references”, is that two kinds of values have reference type: normal references and guarded references. A guarded reference consists of the underlying reference (a memory address) and two coercions, one to apply when reading and another to apply when writing. A guarded reference is created during runtime when a normal reference is casted from one reference type to another. When a compiler for a language
منابع مشابه
Monotonic References for Efficient Gradual Typing
Gradual typing enables both static and dynamic typing in the same program and makes it convenient to migrate code regions between the two typing disciplines. One goal of gradual typing is to provide all the benefits of static typing, such as efficiency, in statically-typed regions. However, this goal is elusive: the standard approach to mutable references imposes run-time overhead in statically...
متن کاملEfficient Gradual Typing
Gradual typing combines static and dynamic typing in the same program. One would hope that the performance in a gradually typed language would range between that of a dynamically typed language and a statically typed language. Existing implementations of gradually typed languages have not achieved this goal due to overheads associated with runtime casts. Takikawa et al. (2016) report up to 100×...
متن کاملTowards Smooth Monotonicity in Fuzzy Inference System based on Gradual Generalized Modus Ponens
Monotonic relationship between input and output often is an inherent property of fuzzy systems. For example, for a cart-pole system, there is a gradual relationship between the pole angle and the cart velocity of the form: “The more the pole deviates from the upright position, the higher velocity the cart must gain”. Thus, we propose an approach, that we call Gradual GMP, which is able to integ...
متن کاملGradual Typestate
Typestate reflects how the legal operations on imperative objects can change at runtime as their internal state changes. A typestate checker can statically ensure, for instance, that an object method is only called when the object is in a state for which the operation is welldefined. Prior work has shown how modular typestate checking can be achieved thanks to access permissions and state guara...
متن کاملRefined Criteria for Gradual Typing
Siek and Taha [2006] coined the term gradual typing to describe a theory for integrating static and dynamic typing within a single language that 1) puts the programmer in control of which regions of code are statically or dynamically typed and 2) enables the gradual evolution of code between the two typing disciplines. Since 2006, the term gradual typing has become quite popular but its meaning...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- CoRR
دوره abs/1312.0694 شماره
صفحات -
تاریخ انتشار 2013