-
Notifications
You must be signed in to change notification settings - Fork 151
Variadic type parameters #1112
Copy link
Copy link
Open
Labels
feature requestNew feature or requestNew feature or request
Description
Right now, using functions with generics is quite awkward in teal, where you cant have any number of function params or returns, you must either take in the entire function as a type or deal with only 1 param/return:
local function my_cool_func<TRet, TArg>(x: function(TArg): TRet, y: TArg): TRet
--some cool invocation magic
endwhere it would fail if you tried to call it with something like:
local function add(x: integer, y: integer): integer
return x + y
end
local val = my_cool_func(add, 1, 2)In order to make this work, you could do something like:
local function my_cool_func<TFn>(x: TFn, ...args: any): any
--some cool invocation magic
endbut now almost all type info is lost.
It would be cool if it would be possible to do "varadict generics", allowing for patterns such as:
local function my_cool_function<TRet, ...TArg>(x: function(TArg...): TRet, ...args: TArg...): TRet
--even safer invocation magic
endReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature requestNew feature or requestNew feature or request