Hi, See below for some comments (after patch 8.2.3751)
On Sat, Aug 21, 2021 at 9:48 AM lacygoill <[email protected]> wrote: > This could be handy for when the opfunc is a script-local function. We > can't write this: > > set operatorfunc=s:MyOpfunc > > This should work now. > Because it raises E120: > > E120: Using <SID> not in a script context: s:MyOpfunc > > So, we have to write this: > > let &operatorfunc = expand('<SID>') .. 'MyOpfunc' > > Which looks a bit weird. > > But with a lambda, we could write this instead: > > set operatorfunc={type\ ->\ s:MyOpfunc(type)} > > One could argue that it still looks weird. I still prefer reading a lambda > which can be used in many other contexts, rather than expand('<SID>'), > which is less often used. > ------------------------------ > > Just 2 remarks. It works with :set but not with :let. That is, we cannot > write this: > > let &operatorfunc = {type -> s:MyOpfunc(type)} > > This should work now. > Because it raises E729: > > E729: Using a Funcref as a String > > It still doesn't work if we manually coerce the lambda into a string: > > let &operatorfunc = {type -> s:MyOpfunc(type)}->string() > ^--------^ > > This also should work now. > Because this time, it raises E129: > > E129: Function name required > > It would be nice if could work so that we don't have to escape spaces: > > # ugly > set operatorfunc={type\ ->\ s:MyOpfunc(type)} > ^ ^ > > # nicer > let &operatorfunc = {type -> s:MyOpfunc(type)} > ^ ^ > > Also, it doesn't work with a Vim9 lambda. That is, in a Vim9 > script/function, we cannot write this: > > set operatorfunc=(type)\ =>\ MyOpfunc(type) > > This should work now. > Because it raises E117: > > E117: Unknown function: (type) => MyOpfunc(type) > > I suspect that's because the option is wrongly evaluated in the legacy > context. Possibly relevant todo item: > > Use the location where the option was set for deciding whether it's to be > evaluated in Vim9 script context. > > As a workaround, we have to use the :legacy modifier: > > legacy set operatorfunc={type\ ->\ MyOpfunc(type)} > ^----^ > > > Can you try the latest version and let us know if you see any problems? Thanks, Yegappan -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/CAAW7x7mM91-R_LZ%2BbsPu2g1TLxa10TOh1zoW98r16GT0WkahJw%40mail.gmail.com.
