changeset 1308:70eecde81820

remove fn,... to improve readability
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 23 Jan 2019 23:37:02 -0700
parents 6c8ceca4a10b
children 5684a14582c4
files conv.txt src/luan/modules/Io.luan src/luan/modules/Thread.luan src/luan/modules/ThreadLuan.java
diffstat 4 files changed, 20 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
diff -r 6c8ceca4a10b -r 70eecde81820 conv.txt
--- a/conv.txt	Wed Jan 23 13:34:18 2019 -0700
+++ b/conv.txt	Wed Jan 23 23:37:02 2019 -0700
@@ -1,3 +1,7 @@
+Thread.fork
+Io.output_to
+Io.output_of
+
 "stringify"
 "Thread.once"
 "Thread.repeating"
diff -r 6c8ceca4a10b -r 70eecde81820 src/luan/modules/Io.luan
--- a/src/luan/modules/Io.luan	Wed Jan 23 13:34:18 2019 -0700
+++ b/src/luan/modules/Io.luan	Wed Jan 23 23:37:02 2019 -0700
@@ -61,25 +61,25 @@
 end
 
 
-function Io.output_to(out,fn,...)
+function Io.output_to(out,fn)
 	local old_out = Io.stdout
-	return try( {
-		function(...)
+	return try {
+		function()
 			Io.stdout = out
-			return fn(...)
-		end;
+			return fn()
+		end
 		finally = function()
 			Io.stdout = old_out
-		end;
-	}, ... )
+		end
+	}
 end
 
 local uri = Io.uri  -- make local
 
-function Io.output_of(fn,...)
+function Io.output_of(fn)
 	local string_uri = uri "string:"
 	local out = string_uri.text_writer()
-	Io.output_to(out,fn,...)
+	Io.output_to(out,fn)
 	out.close()
 	return string_uri.read_text()
 end
diff -r 6c8ceca4a10b -r 70eecde81820 src/luan/modules/Thread.luan
--- a/src/luan/modules/Thread.luan	Wed Jan 23 13:34:18 2019 -0700
+++ b/src/luan/modules/Thread.luan	Wed Jan 23 23:37:02 2019 -0700
@@ -13,19 +13,19 @@
 Thread.sleep = ThreadLuan.sleep
 
 local function safe(fn)
-	return function(...)
-		try( {
+	return function()
+		try {
 			fn
 			catch = function(e)
 				logger.error(e)
 			end
-		}, ... )
+		}
 	end
 end
 
-function Thread.fork(fn,...)
+function Thread.fork(fn)
 	fn = safe(fn)
-	ThreadLuan.fork(fn,...)
+	ThreadLuan.fork(fn)
 end
 
 function Thread.schedule(delay,fn,repeating)
diff -r 6c8ceca4a10b -r 70eecde81820 src/luan/modules/ThreadLuan.java
--- a/src/luan/modules/ThreadLuan.java	Wed Jan 23 13:34:18 2019 -0700
+++ b/src/luan/modules/ThreadLuan.java	Wed Jan 23 23:37:02 2019 -0700
@@ -23,14 +23,13 @@
 	private static final Executor exec = Executors.newCachedThreadPool();
 	public static final ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(1);
 
-	public static void fork(LuanState luan,LuanFunction fn,Object... args) {
+	public static void fork(LuanState luan,LuanFunction fn) {
 		LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE);
 		final LuanState newLuan = (LuanState)cloner.clone(luan);
 		final LuanFunction newFn = (LuanFunction)cloner.get(fn);
-		final Object[] newArgs = cloner.clone(args);
 		exec.execute(new Runnable(){public void run() {
 			try {
-				newFn.call(newLuan,newArgs);
+				newFn.call(newLuan);
 			} catch(LuanException e) {
 				e.printStackTrace();
 			}