From ef991c88921a9366968ef03cfc3a5077f08782b2 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Mon, 12 Sep 2016 15:11:25 +0200 Subject: [PATCH] refactoring --- control.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/control.lua b/control.lua index 14526cd..75138df 100644 --- a/control.lua +++ b/control.lua @@ -67,13 +67,15 @@ function public.on_next_event(event, callback) event_listener(event, function(kill) callback(); kill() end) end -function public.thread(k, ...) auto[arg] = true +function public.vararg.thread(arg) + local k = tremove(arg, 1) local thread_id = unique_id threads[thread_id] = T('k', partial(k, unpack(arg))) return thread_id end -function public.wait(k, ...) auto[arg] = true +function public.vararg.wait(arg) + local k = tremove(arg, 1) if type(k) == 'number' then when(function() k = k - 1 return k <= 1 end, unpack(arg)) else @@ -81,7 +83,9 @@ function public.wait(k, ...) auto[arg] = true end end -function public.when(c, k, ...) auto[arg] = true +function public.vararg.when(arg) + local c = tremove(arg, 1) + local k = tremove(arg, 1) if c() then return k(unpack(arg)) else