Re: [vim/vim] E1041 is thrown when a variable is exported from a script contained in the autoload/ folder and the script is sourced more than once (Issue #19205)
h_east (Vim Github Repository) <[email protected]> Sat, 01 Aug 2026 11:47:16 -0700
| Newsgroups | gmane.editors.vim.devel |
|---|---|
| Message-ID | <vim/vim/issues/19205/[email protected]> |
----==_mimepart_6a6e3f343544b_be11603518010 Content-Type: text/plain; charset="UTF-8" h-east left a comment (vim/vim#19205) @mao-yining Why is restarting Vim a problem here? This is not about the benefit, it is about what it costs in Vim. A class definition is part of the type system. Existing objects hold a pointer to it, member access is compiled to offsets in that definition, and the type is used for checking at compile time. Redefining it while objects exist means rewiring all of that, or keeping two definitions alive at once. That is a structural change, not a small one, and it would affect every Vim9 script whether or not it reloads classes. This is where a language puts its priorities, not a matter of the design being new or old. Your GetInstance() table is at the right layer for this: only the script knows which objects exist and whether they may be thrown away. Vim cannot decide that, throwing away an object is losing data. It also does not remove the cost above: functions in other scripts compiled against the class still hold the member offsets, whether or not your table is empty. Restarting Vim takes well under a second and has none of that risk. You say it is still worth considering. I do not think so. Sorry, but this is my last comment on this topic. -- Reply to this email directly or view it on GitHub: https://github.com/vim/vim/issues/19205#issuecomment-5152870794 You are receiving this because you are subscribed to this thread. Message ID: <vim/vim/issues/19205/[email protected]> -- -- 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 visit https://groups.google.com/d/msgid/vim_dev/vim/vim/issues/19205/5152870794%40github.com. ----==_mimepart_6a6e3f343544b_be11603518010 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div style=3D"display: flex; flex-wrap: wrap; white-space: pre-wrap; align-= items: center; "><img height=3D"20" width=3D"20" style=3D"border-radius:50%= ; margin-right: 4px;" decoding=3D"async" src=3D"https://avatars.githubuserc= ontent.com/u/518808" /><strong>h-east</strong> left a comment <a href=3D"ht= tps://github.com/vim/vim/issues/19205#issuecomment-5152870794">(vim/vim#192= 05)</a></div> <p dir=3D"auto"><a class=3D"user-mention notranslate" data-hovercard-type= =3D"user" data-hovercard-url=3D"/users/mao-yining/hovercard" data-octo-clic= k=3D"hovercard-link-click" data-octo-dimensions=3D"link_type:self" href=3D"= https://github.com/mao-yining">@mao-yining</a><br> Why is restarting Vim a problem here?</p> <p dir=3D"auto">This is not about the benefit, it is about what it costs in= Vim. A class<br> definition is part of the type system. Existing objects hold a pointer to = it,<br> member access is compiled to offsets in that definition, and the type is us= ed<br> for checking at compile time. Redefining it while objects exist means rewi= ring<br> all of that, or keeping two definitions alive at once. That is a structura= l<br> change, not a small one, and it would affect every Vim9 script whether or n= ot<br> it reloads classes. This is where a language puts its priorities, not a ma= tter<br> of the design being new or old.</p> <p dir=3D"auto">Your GetInstance() table is at the right layer for this: on= ly the script knows<br> which objects exist and whether they may be thrown away. Vim cannot decide= <br> that, throwing away an object is losing data. It also does not remove the<= br> cost above: functions in other scripts compiled against the class still hol= d<br> the member offsets, whether or not your table is empty.</p> <p dir=3D"auto">Restarting Vim takes well under a second and has none of th= at risk.</p> <p dir=3D"auto">You say it is still worth considering. I do not think so. = Sorry, but this<br> is my last comment on this topic.</p> <p style=3D"font-size:small;-webkit-text-size-adjust:none;color:#666;">&mda= sh;<br />Reply to this email directly, <a href=3D"https://github.com/vim/vi= m/issues/19205#issuecomment-5152870794">view it on GitHub</a>, or <a href= =3D"https://github.com/notifications/unsubscribe-auth/ACY5DGHJN2IF2HFDPTTE2= YL5HY3LJAVCNFSNUABEKJSXA33TNF2G64TZHM2DAOJZG42DQMR3JFZXG5LFHMZTQMRWGMZDENZU= GCQXMAQ">unsubscribe</a>.<br />Triage notifications, keep track of coding a= gent tasks and review pull requests on the go with GitHub Mobile for <a hre= f=3D"https://github.com/notifications/mobile/ios/ACY5DGBWHQ2MODZEPHV5JKL5HY= 3LJA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMJVGI4DOMBXHE2KM= 4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSVGM33PORSXEX3JN5ZQ">iOS</a> and <a hre= f=3D"https://github.com/notifications/mobile/android/ACY5DGG6JX75K7GWEHSKWJ= L5HY3LJA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMJVGI4DOMBXH= E2KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSXGM33PORSXEX3BNZSHE33JMQ">Android<= /a>. Download it today! <br />You are receiving this because you are subscribed to this thread.<img= src=3D"https://github.com/notifications/beacon/ACY5DGFJUPGDZR54CARI3ND5HY3= LJBFCNFSM6AAAAACSBRTDOCWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3= TUL5UWJTYAAAAACMZCSGFKM4TFMFZW63VKON2WE43DOJUWEZLE.gif" height=3D"1" width= =3D"1" alt=3D"" /><span style=3D"color: transparent; font-size: 0; display:= none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: = 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><vim/vi= m/issues/19205/5152870794</span><span>@</span><span>github</span><span>.</s= pan><span>com></span></span></p> <script type=3D"application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/vim/vim/issues/19205#issuecomment-5152870794"= , "url": "https://github.com/vim/vim/issues/19205#issuecomment-5152870794", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script> <p></p> -- <br /> -- <br /> You received this message from the "vim_dev" maillist.<br /> Do not top-post! Type your reply below the text you are replying to.<br /> For more information, visit <a href=3D"http://www.vim.org/maillist.php">htt= p://www.vim.org/maillist.php</a><br /> <br /> --- <br /> You received this message because you are subscribed to the Google Groups &= quot;vim_dev" group.<br /> To unsubscribe from this group and stop receiving emails from it, send an e= mail to <a href=3D"mailto:[email protected]">vim_dev+uns= [email protected]</a>.<br /> To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/= vim_dev/vim/vim/issues/19205/5152870794%40github.com?utm_medium=3Demail&utm= _source=3Dfooter">https://groups.google.com/d/msgid/vim_dev/vim/vim/issues/= 19205/5152870794%40github.com</a>.<br /> ----==_mimepart_6a6e3f343544b_be11603518010--