C++ guys hate static_if?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Mar 14 10:07:16 PDT 2013
On 3/14/13 12:54 PM, deadalnix wrote:
> On Thursday, 14 March 2013 at 16:48:29 UTC, Andrei Alexandrescu wrote:
>> 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.
>>
>
> I see we agree this is the same problem materialized in another form. I
> find it rather weird that you conclude different things when the problem
> is the same in the first place.
Very simple. Traditionally there's two crucial epochs known as
compilation time and run time. (There's some minor distinctions like
link time etc.) The whole notion of concepts and other type systems for
templates is predicated on three crucial epochs: library compilation
time, library user compilation time, and run time. The logic goes,
someone writes a generic library and wants to distribute it to users.
Users shouldn't ever see bugs caused by e.g. typos in the library.
So the crowd that use meta-type systems is formed of library writers who
want to distribute libraries without ever instantiating them. I don't
think that's a good crowd to cater for.
I've been surprised to figure how many people don't get this flow, or
only have a vague image of it. Although meta-types are arguably "the
right thing" to do, they're a lot less attractive once it's clear what
scenarios they help.
Andrei
More information about the Digitalmars-d
mailing list