More fun with autodecoding

Nick Sabalausky (Abscissa) SeeWebsiteToContactMe at semitwist.com
Sun Sep 16 20:12:57 UTC 2018


On 09/15/2018 04:29 PM, Jonathan M Davis wrote:
> 
> Adding any sort of Concepts feature to D
> would be very much at odds with DbI.

I'm not very familiar with C++'s attempted approaches to concepts, so 
maybe we're thinking of two different things by "concepts", but I don't 
see why it would be at odds with DbI. If anything, they would seem to 
compliment each other well, each one filling in where the other hits its 
limit. Even just a simple example:

void foo(ForwardRange r1, InputRange r2)
if(hasLength!r1)
{...}

Andrei is right that a no-DbI version of that would suck: Hierarchies 
are no good for a series of orthogonal options. But at the same time, 
the equivalent current-D code would comparatively be a mess, too.

Although...and maybe I'm just typing out of my &%@ here, maybe some kind 
of templated concept:

void foo(ForwardRange!WithLength r1, InputRange r2)
{...}


> Overall though, I don't think that there's really any disagreement that it
> would be very desirable to get the compiler to provide better information
> about which parts of a template constraint are true and which are false. The
> problem is really that someone needs to come up with a scheme to do so that
> will work reasonably well and then implement it, and no on has done that
> yet.

Agreed, but let's be realistic, this *is* D: How many years has it been 
since assertPred was rejected in favor of the improved-assert-messages 
vaporware? It's hard to have much faith in such a thing happening here 
either. (Not that I'm under any illusion that concept-like stuff would 
be any more likely.)

Though, I'd be glad to be proven wrong either way.

-- Danny Downer


More information about the Digitalmars-d mailing list