On Thu, May 21, 2020 at 6:05 PM Lifepillar <[email protected]> wrote: > > I have always believed that, in get(X,y,z), z would be evaluated only > when dictionary X does not contain key y. Today, to my surprise, I have > discovered that it is not the case: > > fun! Loop() > call Loop() > endf > > let H = { 'a': 1 } > > if has_key(H, 'a') || Loop() " Fine, this is evaluated lazily > endif > > echo (get(H, 'a') != 0) ? "" : Loop() " Fine, lazy > > " But, endless recursion here: > echo get(H, 'a', Loop()) > > What is the rationale for this behaviour? > > Thanks, > Life.
IIUC, any expression in the arguments of a function (other than a variable of type List, Dictionary, Funcref or Blob) is passed "by value" after having been evaluated by the caller. In get(H, a, Loop()) the third argument passed is the _value_ of Loop() as evaluated immediately before the call. Best regards, Tony. -- -- You received this message from the "vim_use" 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_use" 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_use/CAJkCKXvw8NBTSQY3%3D_D4%3DY5HN%2BS5PqD9UKdr_D%2B%3DhtZW184uxg%40mail.gmail.com.
