D12074: Solve problem of appearance input of interpreter in interpreter's output in Lua backend

Alexander Semke noreply at phabricator.kde.org
Wed Apr 25 20:25:17 UTC 2018


asemke added a comment.


  In D12074#252497 <https://phabricator.kde.org/D12074#252497>, @sirgienko wrote:
  
  > Well, I have worked a lot of time with Octave, Maxima and few times with Python 2, Python 3, Lua, Julia. I have this problem only with lua.
  
  
  The problem is reproducible with these two multi-line commands:
  F5822350: lua_auto_eval_problem.png <https://phabricator.kde.org/F5822350>
  
  The debug output after the first command is executed
  
    final command to be executed  "function fib(n)\n  if n < 2 then return 1 end\n  return fib(n - 2) + fib(n - 1)\nend\n\n-- Closures and anonymous functions are ok:\nfunction adder(x)\n  -- The returned function is created when adder is\n  -- called, and remembers the value of x:\n  return function (y) return x + y end\nend\na1 = adder(9)\na2 = adder(36)\nprint(a1(16))  --> 25\nprint(a2(64))  --> 100\n" 
    
    parsing the output  "function fib(n)\n>>   if n < 2 then return 1 end\n>>   return fib(n - 2) + fib(n - 1)\n>> end\n> \n"
    final output of the command  "function fib(n)\n  if n < 2 then return 1 end\n  return fib(n - 2) + fib(n - 1)\nend\n\n-- Closures and anonymous functions are ok:\nfunction adder(x)\n  -- The returned function is created when adder is\n  -- called, and remembers the value of x:\n  return function (y) return x + y end\nend\na1 = adder(9)\na2 = adder(36)\nprint(a1(16))  --> 25\nprint(a2(64))  --> 100" :  "" 
  
  and after the second command is executed
  
    final command to be executed  "function bar(a, b, c)\n  print(a, b, c)\n  return 4, 8, 15, 16, 23, 42\nend\n\nx, y = bar('zaphod')  --> prints \"zaphod  nil nil\"\n" 
    
    parsing the output  "> -- Closures and anonymous functions are ok:\n> function adder(x)\n>>   -- The returned function is created when adder is\n>>   -- called, and remembers the value of x:\n>>   return function (y) return x + y end\n>> end\n> a1 = adder(9)\n> a2 = adder(36)\n> print(a1(16))  --> 25\n25\n> print(a2(64))  --> 100\n100\n> "
    final output of the command  "function bar(a, b, c)\n  print(a, b, c)\n  return 4, 8, 15, 16, 23, 42\nend\n\nx, y = bar('zaphod')  --> prints \"zaphod  nil nil\"" :  "-- Closures and anonymous functions are ok:\nfunction adder(x)\n-- The returned function is created when adder is\n-- called, and remembers the value of x:\nreturn function (y) return x + y end\na1 = adder(9)\na2 = adder(36)\nprint(a1(16))  --> 25\n25\nprint(a2(64))  --> 100\n100" 
    
    parsing the output  "function bar(a, b, c)\n>>   print(a, b, c)\n>>   return 4, 8, 15, 16, 23, 42\n>> end\n> \n> x, y = bar('zaphod')  --> prints \"zaphod  nil nil\"\nzaphod\tnil\tnil\n> "
    final output of the command  "function bar(a, b, c)\n  print(a, b, c)\n  return 4, 8, 15, 16, 23, 42\nend\n\nx, y = bar('zaphod')  --> prints \"zaphod  nil nil\"" :  "zaphod\tnil\tnil" 
  
  So, the expected result of the first command
  
    25
    100
  
  comes _after_ the second command is executed. Also, there is the third output here with the desired result of the second command
  
    zaphod nil nil
  
  This all looks a bit strange...

REPOSITORY
  R55 Cantor

REVISION DETAIL
  https://phabricator.kde.org/D12074

To: sirgienko, #cantor, asemke
Cc: #cantor, #kde_edu, narvaez, apol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-edu/attachments/20180425/aaa7ffc0/attachment.html>


More information about the kde-edu mailing list