Open ZverGuy opened 1 month ago
Okay Create /specs/extensions.md and describe the specification After pouring in the specification, work on the prototype will begin
Okay Create /specs/extensions.md and describe the specification After pouring in the specification, work on the prototype will begin
Spec merged in upstream @0xF6 for now I'm waiting prototype
Extensions Types or Traits
Summary
Add support to extending class functionality without inheritance or composition
Motivation
Add support to extending class functionality without inheritance can decrease count of boilerplate code
With this feature creating adapters and wrapper for implement interfaces are useless
Just write a extension type or 'impl' for underlying type.
The purpose of "extensions" is to augment or adapt existing types to new scenarios, when those types are not under your control, or where changing them would negatively impact other uses of them. The adaptation can be in the form of adding new function members as well as implementing additional interfaces.
Example
Detailed design
Design based on https://github.com/dotnet/csharplang/blob/main/proposals/extensions.md
Syntax
but unlike c# proposal, in vein lang extension types should support to implement interfaces.
code example
Alternatives
Rust Traits