Vylepšení typové inference v jazyce C#
Improving Type Inference in the C# Language
diploma thesis (DEFENDED)

View/ Open
Permanent link
http://hdl.handle.net/20.500.11956/190675Identifiers
Study Information System: 259059
Collections
- Kvalifikační práce [11326]
Author
Advisor
Referee
Parízek, Pavel
Faculty / Institute
Faculty of Mathematics and Physics
Discipline
Computer Science - Software Systems
Department
Department of Distributed and Dependable Systems
Date of defense
11. 6. 2024
Publisher
Univerzita Karlova, Matematicko-fyzikální fakultaLanguage
Czech
Grade
Excellent
Keywords (Czech)
C#|Roslyn|Typová inferenceKeywords (English)
C#|Roslyn|Type inferenceC# je silně typovaný jazyk využívající typovou inferenci k ušetření typových ano- tací napsaných programátorem. Tato typová inference však není tak silná jako v jiných programovacích jazycích jako Rust nebo Haskell. Tato práce si kladla za cíl navrhnout vylepšení jazyka C#, které by zlepšilo současnou typovou inferenci a které by pravděpodobně bylo přijato týmem návrhářů jazyka C#. Pro tento cíl jsme analyzovali typovou infer- enci v jazyce Rust a určili nezbytné požadavky jazyka a omezení typové inference na základě Hindley-Millnerovy formalizace typové inference. Tato analýza byla použita k návrhu vylepšení jazyka sestávajícího ze dvou částí. První částí je změna specifikace C# popisující vylepšení úpravou formální specifikace C#. Tato část byla představena týmu pro návrh jazyka C#, kterému se návrh líbil, a rozhodl pokračovat v ladění zmíněného vylepšení které by se objevilo v budoucí verzi C#. Druhá část je implementace vylepšení v oficiální kompilátoru jazyka C#, Roslyn. Implementace je testována pomocí originálních testů kompilátoru a nových testů ověřující funkčnost vylepšení. 1
C# is a strongly typed language utilizing type inference to save type annotations writ- ten by a programmer. However, the type inference is not as strong as other programming languages like Rust or Haskell. This thesis goal was to propose the C# language improve- ment which would improve the current type inference and would be likely accepted by the C# language design team. For this achievement, we analyzed Rust's type inference and observed necessary language requirements and type inference restrictions based on Hindley-Millner's formalization of type inference. These observations were used to pro- pose a language improvement consisting of two parts. The first part is a C# specification change describing the improvement by adjusting formal C# specification. This part was presented to the C# language design team which resulted in a positive reaction where the team decided to keep moving forward with the proposal to make it available in the future C# language version. The second part is an implementation of the improvement in the official C# language compiler, Roslyn. The implementation is tested by using the original compiler tests and new tests testing the proposal functionality. 1