C++ guys hate static_if?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Mar 14 09:48:28 PDT 2013
On 3/14/13 11:50 AM, deadalnix wrote:
> On Thursday, 14 March 2013 at 15:38:53 UTC, Andrei Alexandrescu wrote:
>> On 3/14/13 11:05 AM, monarch_dodra wrote:
>>> Having to instantiate a template just to check to make sure it is
>>> semantically correct is a huge pain.
>>
>> I'm not sure about that. The way I see it, no code should be not
>> delivered without being unittested. Ubiquitous unittesting is now
>> mainstream. The way I see it, a type system on top of templates would
>> only help people who don't write unittests.
>>
>> Andrei
>
> The same argument can be made when talking about dynamic vs static typing.
And it has been made indeed. The question is on agreeing or not with
specifics. The stereotypical argument in favor of dynamic typing goes as
follows:
Q: Does static typing detect all bugs?
A: No.
Q: Then unittests are necessary.
A: Correct.
Q: So if static typing is insufficient, why not rely on unittests alone
to do all checking? It's also bothersome for some people to obey types,
annotate stuff etc.
A: There are still errors that can be better detected with static
checking, and many dynamic programs that work by accident etc.
Q: ... I agree or don't agree ...
> This is usualy much better to have the compiler smash your mistake right
> into your face than discovering with a unittest much latter.
I don't think so.
> I don't say that unittest are useless, but why rely on unittest when the
> machine can do the job for you ?
In both cases the machine does the work. My argument is that adding an
additional layer of typing on top of templates caters to people who want
to ship code that has literally zero testing. That's not a priority as
far as I'm concerned.
Andrei
More information about the Digitalmars-d
mailing list