Vylepšení typové inference v jazyce C#
Improving Type Inference in the C# Language
diplomová práce (OBHÁJENO)

Zobrazit/ otevřít
Trvalý odkaz
http://hdl.handle.net/20.500.11956/190675Identifikátory
SIS: 259059
Kolekce
- Kvalifikační práce [11326]
Autor
Vedoucí práce
Oponent práce
Parízek, Pavel
Fakulta / součást
Matematicko-fyzikální fakulta
Obor
Informatika - Softwarové systémy
Katedra / ústav / klinika
Katedra distribuovaných a spolehlivých systémů
Datum obhajoby
11. 6. 2024
Nakladatel
Univerzita Karlova, Matematicko-fyzikální fakultaJazyk
Čeština
Známka
Výborně
Klíčová slova (česky)
C#|Roslyn|Typová inferenceKlíčová slova (anglicky)
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