Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] @mixin - @class specific syntax to define applied mixins #2618

Open
SReject opened this issue Apr 19, 2024 · 1 comment
Open

Comments

@SReject
Copy link

SReject commented Apr 19, 2024

What

A way to indicate that the members of a @class type are applied to a subject @class outside of the inheritance chain

Technical

@mixin type, ...
Adds the values of type, ... to the subject class' definition. Mixins are applied in the order they are specified; values of the same key are overwrote as each mixin is processed

Example

This:

---@class Mixin1
---@field foo number
---@field bar number

---@class Mixin2
---@field bar string
---@field baz string

---@class Subject
---@field key boolean
---@field foo boolean
---@mixin Mixin1, Mixin2

Would get interpreted as

---@class Subject
---@field key boolean (defined by field; wasn't altered by mixins)
---@field foo number (defined by field, overwrote by mixin1, not overwrite by mixin2)
---@field bar string (defined by mixin1, overwrite by mixin2)
---@field baz string (defined by mixin2)

Use case

I currently have sub-classes that get assigned valves from reusable dictionary tables outside their inheritance chain. The only way to document those modifications is to statically define the fields each time a mixin is applied

@SReject SReject changed the title [Feature Request] @mixin - Class-specific syntax to define applied mixins [Feature Request] @mixin - @class specific syntax to define applied mixins Apr 20, 2024
@CppCXY
Copy link
Contributor

CppCXY commented Apr 22, 2024

A future feature ---@class (partial) A may meet your needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants