LuaLS / LuaLS/lua-language-server

feature: Variadic generic packs and mapping expansion

Đang mở
#2,470 0 bình luận 4 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Lua
Star
4.4k
Fork
442
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

#1861

This feature request requests variadic generics functionality, as well as mapping those generics. My proposed implementation of this feature request would allow the following example syntax:

---@generic R, T...
---@param fn fun(...: T...):R
---@param ... Component<T>
---@return System<R>
function System.new(fn, ...)
    ...
end

---@generic R
---@param System<R> self
---@param entities Entity[]
---@return R[]
function System:run()
    ...
end

The example code above also introduces a shorthand for variadics (line 3): whenever the parameter ... would have an unexpanded parameter pack as an argument, it is implicitly expanded. Any type can be expanded at any point by suffixing a ..., as shown in line 2.

The motivation of this request arises from an well-typed ECS implementation with object-oriented systems. Without variadic generics, it is not possible in any way I know of to allow a system to depend on any amount of components and still have well-typed parameters.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với issue liên quan #1861 và các ví dụ Lua được đề xuất trong issue này. Xác định các variadic generic pack, mapping expansion và dạng viết tắt ... nên hoạt động như thế nào, sau đó xác minh rằng System API được minh họa có thể biểu diễn các tham số component và giá trị trả về có kiểu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
lua
Lĩnh vực
devtools
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.