bugfix: print(nil)

akkartik
Nov 9, 2024, 4:47 PM
2KACFSV7BYUNP5L4YP6BGFOCJY26VBOCSC243QG4FCR4X37KCRFQC

Dependencies

  • [2] I52S4E5F running `print` now appends to output editor
  • [3] 7SJHYHMB clean up the setFont gotcha
  • [4] YK5FRJWH print to output buffer in all callbacks
  • [5] 5OCELN37 bugfix in output editor wrapping
  • [6] 2SE2CRDR make print _much_ more efficient
  • [*] R5QXEHUI somebody stop me

Change contents

  • file addition: 0182-map_nil (----------)
    [8.2]
    -- like map, but support nils inside arr
    -- arr must provide its length in an 'n' field,
    -- as returned by 'unpack'.
    map_nil = function(arr, f)
    local result = {}
    for i=1,arr.n do
    result[i] = f(arr[i])
    end
    result.n = arr.n
    return result
    end
  • file addition: 0181-pack (----------)
    [8.2]
    -- like table.pack from Lua 5.2
    -- https://stackoverflow.com/questions/7183998/in-lua-what-is-the-right-way-to-handle-varargs-which-contains-nil/7186820#7186820
    pack = function(...)
    local result = {...}
    result.n = select('#', ...)
    return result
    end
  • replacement in 0050-print_to_output at line 2
    [2.1443][2.1443:1497]()
    local line = table.concat(map({...}, tostring), ' ')
    [2.1443]
    [2.1497]
    local args = pack(...)
    local line = table.concat(map_nil(args, tostring), ' ')