On Monday, September 19, 2016 01:55:58 Timon Gehr via Digitalmars-d wrote:
> On 18.09.2016 22:10, Jonathan M Davis via Digitalmars-d wrote:
> > In
> > this case, a non-static unittest block would be compiled into each
> > template
> > intsantiation, whereas a static one would be compiled once per template
> > and
> > would not require that the template even be instantiated.
> Yes, but those are actually not "pretty much the same".
> The second feature does not exist for any kind of declaration, and it is
> not 'static'. If it is introduced, why limit it to unittests?
The entire point of DIP 82 is to make it so that you can lexically put the
unittest block right after the symbol inside of the template so that it can
be ddoc-ed and so that the test can live right next to what it's testing
without getting compiled into the template. It also makes it so that you
don't have to put unittest blocks outside of the template to ensure that the
template actually gets instantiated for testing. What use case is there for
anything else living inside a template but not actually being part of the
template? For other declarations, you'd just declare them outside of the
template. unittest blocks are a total oddball here, because they need to be
right after the function to work with ddoc, and it's a maintenance problem
for them not to be right next to what they're testing. I don't know of
anything else with similar problems.
- Jonathan M Davis