Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[Lua] Ported multi_matrix code to Lua 5.3
authorChristian Heinrich <franz-christian.heinrich@inria.fr>
Thu, 23 Jul 2015 17:01:11 +0000 (19:01 +0200)
committerChristian Heinrich <franz-christian.heinrich@inria.fr>
Thu, 15 Oct 2015 17:17:18 +0000 (19:17 +0200)
examples/lua/multi_matrix/receiver.lua
examples/lua/multi_matrix/sender.lua

index 6769b5c..0ecf35b 100644 (file)
@@ -7,8 +7,8 @@
 function Receiver(...)
 
   simgrid.info("Hello From Receiver")
 function Receiver(...)
 
   simgrid.info("Hello From Receiver")
-  local sender = simgrid.host.get_by_name(arg[1])
-  local send_alias = arg[2]
+  local sender = simgrid.host.get_by_name(select(1, ...))
+  local send_alias = select(2, ...)
   local recv_alias = "Receiver"
   simgrid.info("Receiving Task from " .. simgrid.host.name(sender))
   local task = simgrid.task.recv(recv_alias)
   local recv_alias = "Receiver"
   simgrid.info("Receiving Task from " .. simgrid.host.name(sender))
   local task = simgrid.task.recv(recv_alias)
index 16166ff..c942ba3 100644 (file)
@@ -4,22 +4,22 @@
 -- This program is free software; you can redistribute it and/or modify it
 -- under the terms of the license (GNU LGPL) which comes with this package.
 
 -- This program is free software; you can redistribute it and/or modify it
 -- under the terms of the license (GNU LGPL) which comes with this package.
 
-function Sender(...) 
+function Sender(...)
 
   simgrid.info("Hello From Sender")
 
   simgrid.info("Hello From Sender")
-  local receiver = simgrid.host.get_by_name(arg[1])
-  local task_comp = arg[2]
-  local task_comm = arg[3]
-  local rec_alias = arg[4]
+  local receiver = simgrid.host.get_by_name(select(1, ...))
+  local task_comp = select(2, ...)
+  local task_comm = select(3, ...)
+  local rec_alias = select(4, ...)
 
   local size = 4
   local m1 = mkmatrix(size, size)
   local m2 = mkmatrix(size, size)
 
 
   local size = 4
   local m1 = mkmatrix(size, size)
   local m2 = mkmatrix(size, size)
 
-  if #arg ~= 4 then
+  if select("#", ...) ~= 4 then
     error("Argc should be 4")
   end
     error("Argc should be 4")
   end
-  simgrid.info("Argc=" .. (#arg) .. " (should be 4)")
+  simgrid.info("Argc=" .. select("#", ...) .. " (should be 4)")
 
   -- Sending Task
   local task = simgrid.task.new("matrix_task", task_comp, task_comm)
 
   -- Sending Task
   local task = simgrid.task.new("matrix_task", task_comp, task_comm)