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 小组 | 第 80 期 March 18, 2020 # Based on Contracts ( Version July 31, 2019 Changkun Ou · Go 夜读 · Go 2 Generics? A (P)review 主要内容 ● 泛型的起源 ● 泛型的早期设计 ● Go 2 的「合约」 ● 上手时间 ● 历史性评述 ● 展望 泛型的起源 Origin of Generics 2020 © Changkun Ou · Go 夜读 · Go 2 Generics? A (P)review 当我们谈论泛型时,我们在谈论什么? float64 的 Add Add("1", "2") // 编译器生成 T = string 的 Add 2020 © Changkun Ou · Go 夜读 · Go 2 Generics? A (P)review 泛型做到了什么接口做不到的事情? 5 当使用 interface{} 时,a、b、返回值都可以在运行时表现为不同类型,取决于内部 实现如何对参数进行断言: type0 码力 | 41 页 | 770.62 KB | 1 年前3Reference guide for Free Pascal, version 3.2.2
Reference counting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 8 Generics 123 8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 8.9 Operator overloading and generics . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 9 Extended records 142 9.1 Definition all types, except the various file types (or complex types containing a file type). Remark • For generics, the use of Default is especially useful, since the type of a variable may not be known during the0 码力 | 268 页 | 700.37 KB | 1 年前3Mypy 1.8.0 Documentation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 1.14 Generics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 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 | 1 年前3Mypy 1.10.0+dev Documentation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 1.14 Generics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 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 | 1 年前3The TypeScript Handbook
Types 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 TypeScript also type 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 a 0 码力 | 184 页 | 647.99 KB | 1 年前3Mypy 1.10.0+dev Documentation
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 type compatibility 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 Generic methods 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 | 1 年前3Mypy 1.8.0 Documentation
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 type compatibility 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 Generic methods 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 | 1 年前3The Rust Programming Language,2nd Edition
is 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 | 1 年前3Go 101 (Golang 101) v1.21.0
polymorphism. §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 and 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 | 1 年前3Go 101 (Golang 101) v1.21.0
polymorphism. §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 Topics 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 and 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 | 1 年前3
共 246 条
- 1
- 2
- 3
- 4
- 5
- 6
- 25