2005 | OriginalPaper | Buchkapitel
Towards Type Inference for JavaScript
verfasst von : Christopher Anderson, Paola Giannini, Sophia Drossopoulou
Erschienen in: ECOOP 2005 - Object-Oriented Programming
Verlag: Springer Berlin Heidelberg
Aktivieren Sie unsere intelligente Suche, um passende Fachinhalte oder Patente zu finden.
Wählen Sie Textabschnitte aus um mit Künstlicher Intelligenz passenden Patente zu finden. powered by
Markieren Sie Textabschnitte, um KI-gestützt weitere passende Inhalte zu finden. powered by
Object-oriented scripting languages like Javascript and Python are popular partly because of their dynamic features. These include the runtime modification of objects and classes through addition of fields or updating of methods. These features make static typing difficult and so usually dynamic typing is used. Consequently, errors such as access to non-existent members are not detected until runtime.
We first develop a formalism for an object based language, JS
0
with features from Javascript, including dynamic addition of fields and updating of methods. We give an operational semantics and static type system for JS
0
using structural types. Our types allow objects to evolve in a controlled manner by classifying members as
definite
or
potential
.
We define a type inference algorithm for JS
0
that is sound with respect to the type system. If the type inference algorithm succeeds, then the program is typeable. Therefore, programmers can benefit from the safety offered by the type system, without the need to write explicitly types in their programs.