diff core/src/luan/cmd_line.luan @ 326:db37d6aee4db

remove try-catch statement; add Luan.try() and Luan.pcall(); git-svn-id: https://luan-java.googlecode.com/svn/trunk@327 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Thu, 19 Mar 2015 00:01:57 +0000
parents cd2924a1052c
children dc21bd260690
line wrap: on
line diff
--- a/core/src/luan/cmd_line.luan	Tue Mar 03 06:00:59 2015 +0000
+++ b/core/src/luan/cmd_line.luan	Thu Mar 19 00:01:57 2015 +0000
@@ -2,6 +2,7 @@
 local ipairs = Luan.ipairs
 local load = Luan.load
 local load_file = Luan.load_file
+local try = Luan.try
 require "luan:String"  -- for String methods
 local Table = require "luan:Table"
 local Io = require "luan:Io"
@@ -72,12 +73,15 @@
 	for j,v in ipairs(args) do
 		Luan.arg[j-i] = v
 	end
-	try
-		local main_file = load_file("file:"..file)
-		main_file( Table.unpack(Luan.arg) )
-	catch e do
-		Io.print_to(Io.stderr, e )
-	end
+	try {
+		function()
+			local main_file = load_file("file:"..file)
+			main_file( Table.unpack(Luan.arg) )
+		end;
+		catch = function(e)
+			Io.print_to(Io.stderr, e )
+		end;
+	}
 end
 if interactive then
 	Debug.debug("> ")