Ben Schmidt wrote:
> While working on the Float printing function, I also noted an odd Vim > behaviour: it won't let you assign a Float to a variable that was > previously a Number, and vice-versa. Or for that matter, it won't let > you change the type of a variable at all with an assignment. > > The trouble is in the set_var() function. Consider the following patch > (it is applied to my patched Vim, so line numbers will be ridiculously > different to the original, probably, but should apply cleanly and can be > found manually by :tag set_var): Thanks, this makes sense. Except that we should not allow conversion between String and Float. > The first hunk patches the variable type mismatch check so that it > allows floats to be included as allowed type changes. > > However, why is this check there? I don't see any reason changing a > variable type to or from a list, dictionary or function reference would > cause any problems either. References are correctly updated by a call to > clear_tv shortly after the check, and tv and v->tv could not reference > the same variable and include a change in type, so there is no chance of > freeing a structure that is about to be used. Couldn't the check be > safely removed and thus enable variables to be freely assigned values of > new types? It's called sticky type checking. Not everybody likes it, but that's the way it is. > The second hunk seems to be purely an optimisation, avoiding an > unnecessary call to init_tv in the else part. It applies equally to > Floats as Numbers, I think. Yes. > I will leave you to consider it, Bram. As I'm not all that familiar with > the codebase, I may have missed something, but I think I've checked it > out thoroughly enough. -- hundred-and-one symptoms of being an internet addict: 80. At parties, you introduce your spouse as your "service provider." /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---