copy how Lua 5.3 REPL prints expr values

[?]
Apr 26, 2022, 5:10 AM
O2UAHLOVG324OWG6YMZTZOL6ZPT7IU4JKZFHWWIMOFB74EK4KKUAC

Dependencies

Change contents

  • edit in mu.lua at line 7
    [2.121][2.121:216]()
    -- unclear how Lua (post 5.2) is able to selectively print values of variables
    -- at the repl
  • replacement in mu.lua at line 34
    [2.710][2.710:745]()
    local f, err = load(buf, 'REPL')
    [2.710]
    [2.745]
    local f, err = load('return '..buf, 'REPL')
  • replacement in mu.lua at line 47
    [2.1031][2.1031:1206]()
    stdscr:addstr(err..'\n')
    if string.match(err, "'<eof>'$") or string.match(err, "<eof>$") then
    buf = buf .. '\n'
    new_expr = false
    else
    print(err)
    [2.1031]
    [2.1206]
    local f, err = load(buf, 'REPL')
    if f then
  • edit in mu.lua at line 51
    [2.1243]
    [2.1243]
    local success, results = gather_results(xpcall(f, function(...) return debug.traceback() end))
    if success then
    for _, result in ipairs(results) do
    print(result)
    end
    else
    print(results[1])
    end
    else
    stdscr:addstr(err..'\n')
    if string.match(err, "'<eof>'$") or string.match(err, "<eof>$") then
    buf = buf .. '\n'
    new_expr = false
    else
    print(err)
    buf = ''
    new_expr = true
    end