digitalmars.D.learn - Q: Hiding template implementation
- Myron Alexander (4/4) Jun 12 2007 Hello.
- Kirk McDonald (15/22) Jun 12 2007 You can't. Templates don't compile to anything on their own. Object code...
- Myron Alexander (9/20) Jun 12 2007 I was hoping there was some clever option I was missing :) I eventually
Hello. How do you hide the template implementation when compiling a library? Regards, Myron.
Jun 12 2007
Myron Alexander wrote:Hello. How do you hide the template implementation when compiling a library? Regards, Myron.You can't. Templates don't compile to anything on their own. Object code for them is only generated when the template is instantiated. In order to instantiate a template, the code using the template needs full access to the template's source. D's templates are very much like C++'s templates in this respect. The following is somewhat relevant: http://www.parashift.com/c++-faq-lite/templates.html#faq-35.12 (Though note it is about C++ and not D, so many of the specifics are different.) -- Kirk McDonald http://kirkmcdonald.blogspot.com Pyd: Connecting D and Python http://pyd.dsource.org
Jun 12 2007
Kirk McDonald wrote:You can't. Templates don't compile to anything on their own. Object code for them is only generated when the template is instantiated. In order to instantiate a template, the code using the template needs full access to the template's source. D's templates are very much like C++'s templates in this respect. The following is somewhat relevant: http://www.parashift.com/c++-faq-lite/templates.html#faq-35.12 (Though note it is about C++ and not D, so many of the specifics are different.)I was hoping there was some clever option I was missing :) I eventually realized that the current implementation does not do what I believe would be a major boon for library writers and users so I started a thread on d.D about creating a new form of binary module. P.S. What do you think of the changes to D-DBAPI, along the lines of what you wanted? Regards, Myron.
Jun 12 2007