July 25, 2015
Walter Bright <newshound2@digitalmars.com> wrote:
> On 7/23/2015 10:39 PM, Tobias Müller wrote:
>> You may aus well ask "How do interfaces in OO programming deal with this?".
> 
> It's a good question. And the answer is, the top level function does not list every interface used by the call tree. Nested function calls test at runtime if a particular interface is supported by an object, using dynamic casting or QueryInterface() calls. It's fundamentally different from traits and concepts.

IMO dynamic casting or QueryInterface() is a sign of bad design.
But then again, I also like exception specifications, at least the way Java
does it. In C++ they're pointless, that true.

Tobi
July 25, 2015
Walter Bright <newshound2@digitalmars.com> wrote:
> It's also clear that traits work very well "in the small", i.e. in
> specifications of the feature, presentation slide decks, tutorials, etc.
> Just like Exception Specifications did. It's the complex hierarchies where it fell apart.

I'm not convinced at all that checked exceptions (as implemented in Java,
not C++) don't work.

My suspicion is that the usual Java code monkey is just too sloppy to care and thus sees it more as a nuisance rather than the help that it is.

I think Rust attracts a different kind of programmer than Java.

Tobi
July 25, 2015
Walter Bright <newshound2@digitalmars.com> wrote:
> On 7/23/2015 10:49 PM, Tobias Müller wrote:
>> Walter Bright <newshound2@digitalmars.com> wrote:
>>> I know a lot of the programming community is sold on exclusive constraints (C++ concepts, Rust traits) rather than inclusive ones (D constraints). What I don't see is a lot of experience actually using them long term. They may not turn out so well, like ES.
>> 
>> Haskell has type classes since ~1990.
> 
> Haskell is sometimes described as a bondage-and-discipline language. Google it if you don't believe me :-) Such languages have their place and adherents, but I don't think D is directed that way.

I just wanted to point out that there *is* long time experience. What you're thinking about haskell is besides the point.

Tobi
July 25, 2015
Walter Bright <newshound2@digitalmars.com> wrote:
> On 7/23/2015 12:50 PM, Tobias Müller wrote:
>> TBH I'm very surprised about that argument, because boolean conditions with version() were dimissed for exactly that reason.
> 
> I knew someone would bring that up :-)
> 
> No, I do not believe it is the same thing. For one thing, you cannot test the various versions on one system. On any one system, you have to take on faith that you didn't break the version blocks on other systems.
> 
> This is quite unlike D's template constraints, where all the combinations can be tested reliably with a unittest{} block.

How is this related to testability? Using boolean conditions does not introduce any new code paths compared to helper versions/ helper traits. Testability is exactly the same.

My point was that you argued with cleaner design in the case of versions.
*I agree with that*, and I think the same is true for traits.
Even if you're right and testability is better, that doesn't contradict the
point that I'm trying to make.

Tobi
July 25, 2015
Walter Bright <newshound2@digitalmars.com> wrote:
> On 7/24/2015 8:43 PM, Tofu Ninja wrote:
>> there is just a type at the top of the tree that
>> implements them all
> 
> The one type that encompasses everything defeats the whole point of type checking, traits, concepts, etc.

That's exactly my feeling with dynamic casts / QueryInterface... Pass 'object' everywhere and then cast it to the desired interface in demand.

Tobi
July 25, 2015
Walter Bright <newshound2@digitalmars.com> wrote:
> BTW, you might want to remove the UTF-8 characters from your user name. Evidently, NNTP doesn't do well with them.

I don't think NNTP has any problems with that. My newsreader displays it just fine.

Tobi
July 25, 2015
Walter Bright <newshound2@digitalmars.com> wrote:
> They write it something like:
> 
>     void foo(hasPrefix t) {
>        t.prefix();
>        s = cast(hasSuffix)t;
>        if (s) bar(s);
>        else RuntimeError(message);
>     }

That's horrible!

Tobi
July 25, 2015
Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote:
>Once we agree on that, we figure that concepts help nobody.

You keep saying that, but I cannot find an explanation. Care to elaborate or give me a pointer?

Tobi
July 25, 2015
On 7/25/2015 2:53 AM, Jonathan M Davis wrote:
> Oh, definitely. But while 100% unit test coverage is a huge step forward, I also
> think that for truly solid code, you want to go beyond that and make sure that
> you test corner cases and the like, test with a large enough variety of types
> with templates to catch behavioral bugs, etc. So, I don't think that we want to
> stop at 100% code coverage, but we do need to make sure that we're at 100% first
> and foremost.

There's another thing I discovered. If functions are broken up into smaller logical units, the unit testing gets easier and there are fewer bugs. For example, the dmd code that reads the dmd.conf file was one function that read the files, allocated memory, did the parsing, built the data structures, etc.

By splitting all these things up, suddenly it gets a lot easier to test! For example, just use the normal file I/O functions to read the files, which are tested elsewhere. Boom, don't need to construct test files. The parsing logic can be easily handled by its own unit tests. And so on.

I think there's also a learned skill to having the fewest number of orthogonal unit tests that give 100% coverage, rather than a blizzard of tests that overlap each other.


>> (I remember the calculator revolution. It happened my freshman year at
>> college. September 1975 had $125 slide rules in the campus bookstore. December
>> they were at $5 cutout prices, and were gone by January. I never saw anyone
>> use a slide rule again. I've never seen a technological switchover happen so
>> fast, before or since.)
>
> If only folks thought that D's advantages over C++ were that obvious. ;)

Unfortunately, D's advantages only become more than a grab-bag of features after you've used it for a while. We are also still discovering the right way to use them.

July 25, 2015
On 7/25/2015 3:30 AM, Russel Winder via Digitalmars-d wrote:
> Conversely someone should fix the NNTP implementation to deal properly
> with UTF-8 encoded Unicode codepoints.

I propose that you do it!