LuaLS / LuaLS/lua-language-server
feature: Variadic generic packs and mapping expansion
まだ誰も着手していません。
- 主要言語
- Lua
- スター
- 4.4k
- フォーク
- 442
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
#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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
関連する issue #1861 と、この issue で提案されている Lua の例から始めます。可変長ジェネリックパック、マッピング展開、... の省略記法がどのように振る舞うべきかを定義し、次に、示されている System API で型付きのコンポーネントパラメーターと戻り値を表現できることを検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100