Go 2 Generics? A (P)review## Go 2 Generics? A (P)review ## Changkun Ou  https://changkun.de/s/go2generics/ https://youtu.be/E16Y6bI2S08 Go 夜读 SIG 2020 ## 主要内容 - 泛型的起源 - 泛型的早期设计 - Go 2 的「合约」 - 上手时间 - 历史性评述 - 展望 ## 泛型的起源 Origin of Generics 多态是同一形式表现出不同行为的一种特性。在编程语言理论中被分为两类: 临时性多态(Ad hoc Polymorphism)根据实参类型调用对应的版本,仅支持数量有限的调用。也被翻译为特设多态。例如:函数重载 ... } // T 是类型参数 泛型的总体目标就是: 快且安全。在这里: 快 意味着静态类型 安全 意味着编译早期的错误甄别 ## 泛型的早期设计 Early Designs on Generics ## 从 Go 1 谈起  来源:0 码力 | 41 页 | 770.62 KB | 2 年前3
Comprehensive Rust(Ukrainian) 202412Курс охоплює весь спектр Rust, від базового синтаксиса до складних тем, таких як узагальнення (generics) и обробка помилок. Останню версію курсу можна знайти за адресою https://google.github.io/comprehensive-rust/0 码力 | 396 页 | 1.08 MB | 1 年前3
Mypy 1.10.0+dev DocumentationType narrowing ..... 56 1.12 Duck type compatibility ..... 62 1.13 Stub files ..... 63 1.14 Generics ..... 65 1.15 More types ..... 80 1.16 Literal types and Enums ..... 95 1.17 TypeDict ... convenient. Mypy has a powerful and easy-to-use type system, supporting features such as type inference, generics, callable types, tuple types, union types, structural subtyping and more. Using mypy will make your forward references for more details. #### 1.2.8 Decorators Decorator functions can be expressed via generics. See Declaring decorators for more details. from typing import Any, Callable, TypeVar F = TypeVar('F'0 码力 | 234 页 | 913.89 KB | 2 年前3
The TypeScript HandbookTypes from Types|An overview of the ways in which you can create more types from existing types.| |Generics|Types which take parameters| |Keyof Type Operator|Using the keyof operator in type contexts.| |Typeof Array, which means the same thing. We'll learn more about the syntax T when we cover generics. Note that [number] is a different thing; refer to the section on Tuples. ## any any. It'd be better if the function returned the type of the array element. In TypeScript, generics are used when we want to describe a correspondence between two values. We do this by declaring a0 码力 | 184 页 | 647.99 KB | 2 年前3
Mypy 1.8.0 DocumentationType narrowing ..... 57 1.12 Duck type compatibility ..... 63 1.13 Stub files ..... 63 1.14 Generics ..... 65 1.15 More types ..... 80 1.16 Literal types and Enums ..... 96 1.17 TypeDict ... convenient. Mypy has a powerful and easy-to-use type system, supporting features such as type inference, generics, callable types, tuple types, union types, structural subtyping and more. Using mypy will make your forward references for more details. #### 1.2.8 Decorators Decorator functions can be expressed via generics. See Declaring decorators for more details. from typing import Any, Callable, TypeVar F = TypeVar('F'0 码力 | 234 页 | 902.89 KB | 2 年前3
The Rust Programming Language,2nd Editionis a feature of Rust we haven’t talked about yet. It’s a generic type parameter, and we’ll cover generics in more detail in Chapter 10. For now, all you need to know is thatmeans the Some variant of may store many values, but those values must all be the same type. Vectors are implemented using generics, which Chapter 10 will cover how to use in your own types. For now, all you need to know is that String { This isn’t the exact signature that’s in the standard library; there add is defined using generics. Here, we’re looking at the signature of add with concrete types substituted for the generic ones 0 码力 | 617 页 | 1.54 MB | 2 年前3
Mypy 1.10.0+dev Documentationconvenient. Mypy has a powerful and easy-to-use type system, supporting features such as type inference, generics, callable types, tuple types, union types, structural subtyping and more. Using mypy will make your Stub files - Creating a stub - Stub file syntax - Using stub file syntax at runtime - Generics - Defining generic classes - Defining subclasses of generic classes - Generic functions name forward references for more details. ## Decorators Decorator functions can be expressed via generics. See Declaring decorators for more details. from typing import Any, Callable, TypeVar F = TypeVar('F'0 码力 | 318 页 | 270.84 KB | 2 年前3
Mypy 1.8.0 Documentationconvenient. Mypy has a powerful and easy-to-use type system, supporting features such as type inference, generics, callable types, tuple types, union types, structural subtyping and more. Using mypy will make your files • Creating a stub • Stub file syntax • Using stub file syntax at runtime • Generics • Defining.generic classes • Defining subclasses of generic classes • Generic name forward references for more details. ## Decorators Decorator functions can be expressed via generics. See Declaring decorators for more details. from typing import Any, Callable, TypeVar F = TypeVar('F'0 码力 | 318 页 | 271.55 KB | 2 年前3
Go 101 (Golang 101) v1.21.0polymorphism. ☐ §24. Type Embedding - type extension in the Go way. ☐ §25. Type-Unsafe Pointers §26. Generics - use and read composite types ☐ §27. Reflections - the reflect standard package. ## • Some Special doesn't touch custom generics in depth. Please read the Go Generics 101 book to learn about custom generics. In addition, type parameter types (used frequently in custom generics) are deliberately ignored comparison rules. In other words, this book doesn't consider the situations in which custom generics are involved. (The Go 101 book is still being improved frequently from time to time. Please visit0 码力 | 630 页 | 3.77 MB | 2 年前3
Go 101 (Golang 101) v1.21.0polymorphism. ☐ §24. Type Embedding - type extension in the Go way. ☐ §25. Type-Unsafe Pointers ☐ §26. Generics - use and read composite types ☐ §27. Reflections - the reflect standard package. ## • Some Special doesn't touch custom generics in depth. Please read the Go Generics 101 book to learn about custom generics. In addition, type parameter types (used frequently in custom generics) are deliberately ignored comparison rules. In other words, this book doesn't consider the situations in which custom generics are involved. (The Go 101 book is still being improved frequently from time to time. Please visit0 码力 | 610 页 | 945.17 KB | 2 年前3
共 231 条
- 1
- 2
- 3
- 4
- 5
- 6
- 24













