From aa3199def734b492059fcaccdebd3cde85cb8547 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 2 Sep 2024 17:48:36 -0300 Subject: Teal: make schedule_function generic --- src/luarocks/util.lua | 6 +++--- src/luarocks/util.tl | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 7035f305..0ea480be 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua @@ -56,8 +56,8 @@ local scheduled_functions = {} -function util.schedule_function(f, ...) - local item = { fn = f, args = _tl_table_pack(...) } +function util.schedule_function(f, x) + local item = { fn = f, arg = x } table.insert(scheduled_functions, item) return item end @@ -87,7 +87,7 @@ function util.run_scheduled_functions() end for i = #scheduled_functions, 1, -1 do local item = scheduled_functions[i] - item.fn(_tl_table_unpack(item.args, 1, item.args.n)) + item.fn(item.arg) end end diff --git a/src/luarocks/util.tl b/src/luarocks/util.tl index 823ee1db..80d39b16 100644 --- a/src/luarocks/util.tl +++ b/src/luarocks/util.tl @@ -24,8 +24,8 @@ local record util matchquote: function(string): string record Fn - fn: function(...: any) - args: table.PackTable + fn: function(any) + arg: any end end @@ -56,8 +56,8 @@ local scheduled_functions: {Fn} = {} -- @param ... arguments to be passed to function. -- @return table: A token representing the scheduled execution, -- which can be used to remove the item later from the list. -function util.schedule_function(f: function(...: any), ...:any): Fn - local item: Fn = { fn = f, args = table.pack(...) } +function util.schedule_function(f: function(X...), x?: X): Fn + local item: Fn = { fn = f, arg = x } table.insert(scheduled_functions, item) return item end @@ -87,7 +87,7 @@ function util.run_scheduled_functions(): string --! a hack for xpcall end for i = #scheduled_functions, 1, -1 do local item = scheduled_functions[i] - item.fn(table.unpack(item.args, 1, item.args.n)) + item.fn(item.arg) end end -- cgit v1.2.3-55-g6feb