digitalmars.D - name resolution in module imports
- Jon Perez (13/13) Oct 01 2010 In the Youtube tech talk by Andrei (
- Justin Johansson (2/15) Oct 01 2010 Is this a recap of DLL-hell?
- Denis Koroskin (6/27) Oct 01 2010 Usually, you need to specify the DLL for each function that is not defin...
- Jon Perez (4/7) Oct 01 2010 Ah yes, right. So if game.exe called drawcircle(int,int)
- =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= (22/38) Oct 01 2010 tion
In the Youtube tech talk by Andrei ( http://www.youtube.com/watch?v=RlVpPstLPEc ), the audience member raises a point at 34:20 about how code that does not qualify a module in a function call, and just relies on function signatures to know which module this belongs to may break if a newer version of the modules it imports suddenly puts into the namespace a new function with the same signature as another module. Andrei argues that this is a deliberate trade-off. I think this is fine in a statically linked library context because the binaries you ship never break anyway. But what about in a dynamically linked library scenario? game.exe links to module1.dll and module2.dll and calls drawcircle(int,int) which is not defined in module2 right now, but what if module2.dll gets updated in the future and suddenly introduces a drawcirlce(int,int) as well? Now game.exe will throw a runtime error.
Oct 01 2010
On 2/10/2010 2:19 AM, Jon Perez wrote:In the Youtube tech talk by Andrei ( http://www.youtube.com/watch?v=RlVpPstLPEc ), the audience member raises a point at 34:20 about how code that does not qualify a module in a function call, and just relies on function signatures to know which module this belongs to may break if a newer version of the modules it imports suddenly puts into the namespace a new function with the same signature as another module. Andrei argues that this is a deliberate trade-off. I think this is fine in a statically linked library context because the binaries you ship never break anyway. But what about in a dynamically linked library scenario? game.exe links to module1.dll and module2.dll and calls drawcircle(int,int) which is not defined in module2 right now, but what if module2.dll gets updated in the future and suddenly introduces a drawcirlce(int,int) as well? Now game.exe will throw a runtime error.Is this a recap of DLL-hell?
Oct 01 2010
On Fri, 01 Oct 2010 20:19:01 +0400, Jon Perez <jbperez808 yahoo.com> wrote:In the Youtube tech talk by Andrei ( http://www.youtube.com/watch?v=RlVpPstLPEc ), the audience member raises a point at 34:20 about how code that does not qualify a module in a function call, and just relies on function signatures to know which module this belongs to may break if a newer version of the modules it imports suddenly puts into the namespace a new function with the same signature as another module. Andrei argues that this is a deliberate trade-off. I think this is fine in a statically linked library context because the binaries you ship never break anyway. But what about in a dynamically linked library scenario? game.exe links to module1.dll and module2.dll and calls drawcircle(int,int) which is not defined in module2 right now, but what if module2.dll gets updated in the future and suddenly introduces a drawcirlce(int,int) as well? Now game.exe will throw a runtime error.Usually, you need to specify the DLL for each function that is not defined in your code. You can do it by either linking with a .lib or .def file. Both map function name to concrete DLL. Either way, once an executable compiled there is a correspondence from each function to a .DLL file, and thus situation you describe is impossible.
Oct 01 2010
Either way, once an executable compiled there is a correspondence from each function to a .DLL file, and thus situation you describe is impossible.Ah yes, right. So if game.exe called drawcircle(int,int) in module1 at the time it was compiled, it will know to keep calling that even if module2.dll now has a function with the same name and signature.
Oct 01 2010
Jon Perez wrote:In the Youtube tech talk by Andrei ( http://www.youtube.com/watch?v=3DRlVpPstLPEc ), the audience member rai=ses apoint at 34:20 about how code that does not qualify a module in a func=tioncall, and just relies on function signatures to know which module this =belongsto may break if a newer version of the modules it imports suddenly puts=intothe namespace a new function with the same signature as another module.==20 Andrei argues that this is a deliberate trade-off. I think this is fin=e in astatically linked library context because the binaries you ship never b=reakanyway. But what about in a dynamically linked library scenario? =20 game.exe links to module1.dll and module2.dll and calls drawcircle(int,=int)which is not defined in module2 right now, but what if module2.dll gets=updated in the future and suddenly introduces a drawcirlce(int,int) as =well?Now game.exe will throw a runtime error. =20What Andrei describes is only valid at the source code level. Once the program is compiled, it doesn't use "drawcircle(int,int)" to identify the function, instead it uses the mangled name which includes the module name anyway. Jerome PS: BTW, this has nothing to do with static vs dynamic linking. If you link statically against module1 and module2 and they both contain a function named drawcircle(int,int) then a file may still call the unqualified drawcircle if it imports only one of the modules. --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Oct 01 2010