digitalmars.D - D's templates now seem weak to me...
- Ben Phillips (3/3) Feb 20 2006 According to the docs, "Templates cannot be used to add non-static membe...
- Stewart Gordon (15/18) Feb 20 2006 Because at the time of compiling the module, one cannot be sure what
- Ben Phillips (6/15) Feb 20 2006 That makes sense. However, couldn't this be fixed by just not compiling ...
- Stewart Gordon (14/31) Feb 21 2006 What if different modules of an application call the template function
- Sean Kelly (5/8) Feb 20 2006 It's also not entirely true. Templates cannot be used to add virtual
- Ben Phillips (2/10) Feb 20 2006 Ah... thanks! The info you and Oskar provided helped me a lot!
According to the docs, "Templates cannot be used to add non-static members or functions to classes. For example: [...]". Why? This is just plain stupid in my opinion
Feb 20 2006
Ben Phillips wrote:According to the docs, "Templates cannot be used to add non-static members or functions to classes. For example: [...]". Why? This is just plain stupid in my opinionBecause at the time of compiling the module, one cannot be sure what types it will be called on, and so it wouldn't be able to generate the vtbl. However, it ought to be possible to do it on private and final member functions, since such things will never be overridden and so don't need to be included in the vtbl. Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Feb 20 2006
In article <dtcr4g$254q$1 digitaldaemon.com>, Stewart Gordon says...Ben Phillips wrote:That makes sense. However, couldn't this be fixed by just not compiling the template functions when creating a *.lib? The end user has to import the appropriate files anyways so it should be possible for the compiler to delay compilation of the functions until an executable is made (kind of like C++ though C++ uses preprocessor #includes)According to the docs, "Templates cannot be used to add non-static members or functions to classes. For example: [...]". Why? This is just plain stupid in my opinionBecause at the time of compiling the module, one cannot be sure what types it will be called on, and so it wouldn't be able to generate the vtbl. However, it ought to be possible to do it on private and final member functions, since such things will never be overridden and so don't need to be included in the vtbl.
Feb 20 2006
Ben Phillips wrote:In article <dtcr4g$254q$1 digitaldaemon.com>, Stewart Gordon says...What if different modules of an application call the template function with different template arguments? The vtbl needs to be known when compiling each module. And so each module would have a different vtbl for the same class, which would totally screw up the program. Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.Ben Phillips wrote:That makes sense. However, couldn't this be fixed by just not compiling the template functions when creating a *.lib? The end user has to import the appropriate files anyways so it should be possible for the compiler to delay compilation of the functions until an executable is made (kind of like C++ though C++ uses preprocessor #includes)According to the docs, "Templates cannot be used to add non-static members or functions to classes. For example: [...]". Why? This is just plain stupid in my opinionBecause at the time of compiling the module, one cannot be sure what types it will be called on, and so it wouldn't be able to generate the vtbl. However, it ought to be possible to do it on private and final member functions, since such things will never be overridden and so don't need to be included in the vtbl.
Feb 21 2006
Ben Phillips wrote:According to the docs, "Templates cannot be used to add non-static members or functions to classes. For example: [...]". Why? This is just plain stupid in my opinionIt's also not entirely true. Templates cannot be used to add virtual members or functions to classes, but they can add (implicitly final) non-static membes to classes. This is the same as in C++. Sean
Feb 20 2006
In article <dtd2gb$2dcn$1 digitaldaemon.com>, Sean Kelly says...Ben Phillips wrote:Ah... thanks! The info you and Oskar provided helped me a lot!According to the docs, "Templates cannot be used to add non-static members or functions to classes. For example: [...]". Why? This is just plain stupid in my opinionIt's also not entirely true. Templates cannot be used to add virtual members or functions to classes, but they can add (implicitly final) non-static membes to classes. This is the same as in C++. Sean
Feb 20 2006