|
2 | 2 |
|
3 | 3 | ## Polymorphism classification |
4 | 4 |
|
5 | | -1. Ad-hoc polymorphism |
6 | | - - Function and method overloading |
7 | | - - Operator overloading |
8 | | - - Type-class polymorphism (e.g. Haskell type classes, Rust traits) |
9 | | - - Coercion polymorphism |
10 | | -2. Subtype polymorphism |
11 | | - - Class inheritance |
12 | | - - Interface / protocol polymorphism |
13 | | - - Structural (duck typing) polymorphism |
14 | | -3. Parametric polymorphism |
15 | | - - Generic functions |
16 | | - - Generic data structures |
17 | | -4. Dispatch mechanisms |
18 | | - - Dynamic dispatch |
19 | | - - Virtual functions and methods |
20 | | - - Multiple or multimethod dispatch |
21 | | - |
22 | | -## Old video |
23 | | - |
24 | | -[](https://youtu.be/8OuzIAuMfjw) |
| 5 | +1. Ad-hoc polymorphism - Functions or operators behave differently based on argument types |
| 6 | + - Function and method overloading - Multiple functions with same name, different signatures |
| 7 | + - CSharp example: [`1-ad-hoc.cs`](Classification/1-ad-hoc.cs) |
| 8 | + - JavaScript emulation: [`2-emulation.js`](Classification/2-emulation.js) |
| 9 | + - Operator overloading - Custom behavior for built-in operators: [`3-operator.cpp`](Classification/3-operator.cpp) |
| 10 | + - Type-class polymorphism - Ad-hoc polymorphism via type constraints (e.g. Haskell type classes, Rust traits) |
| 11 | + - Coercion polymorphism - Implicit or explicit type conversions: [`4-coercion.js`](Classification/4-coercion.js) |
| 12 | +2. Subtype polymorphism - Objects of derived types can be used where base types are expected |
| 13 | + - Class inheritance - IS-A relationship via base classes: [`5-abstract.ts`](Classification/5-abstract.ts) |
| 14 | + - Interface / protocol polymorphism - Contracts that types must implement: [`6-protocol.js`](Classification/6-protocol.js) |
| 15 | + - Structural (duck typing) polymorphism - Compatibility based on structure, not explicit inheritance: [`6-protocol.js`](Classification/6-protocol.js) |
| 16 | +3. Parametric polymorphism - Code written generically to work with any type (examples will be added ASAP) |
| 17 | + - Generic functions - Functions parameterized by types |
| 18 | + - Generic data structures - Data structures parameterized by types |
| 19 | +4. Dispatch mechanisms - How the runtime selects which method to call |
| 20 | + - Dynamic dispatch - Method chosen at runtime based on object type: [`7-dynamic.js`](Classification/7-dynamic.js) |
| 21 | + - Virtual functions and methods - Base class methods overridable by derived classes: [`8-virtual.cpp`](Classification/8-virtual.cpp) |
| 22 | + - Multiple or multimethod dispatch - Method chosen based on multiple argument types |
0 commit comments