nvim-lua / plenary.nvim

plenary: full; complete; entire; absolute; unqualified. All the lua functions I don't want to write twice.
MIT License
2.58k stars 276 forks source link

fun.bind is incorrect for more than one argument #385

Open idbrii opened 2 years ago

idbrii commented 2 years ago

fun.bind incorrectly adds arguments after unpacking. This line in particular:

fn(tbl.unpack(args), ...)

The call to unpack will only get the first argument since there are additional arguments after it.

Failing example:

local pr = fun.bind(print, "hello", "world")
pr("!")

Actual Output:

hello   !

Expected:

hello   world   !

Maybe instead it should be implemented like lume.fn. lume's a great util library and also uses the MIT license.

danielo515 commented 1 year ago

By the way, isn't bind redundant with functional.apply? Apply seems to be correct (and simpler). bind looks like an old forgotten utility that is no longer used?