Feedback on Átila's Vision for D

Paul Backus snarwin at gmail.com
Wed Oct 16 13:07:30 UTC 2019


On Wednesday, 16 October 2019 at 06:53:37 UTC, Sebastiaan Koppe 
wrote:
> Surely it would be possible to define a partial ordering over 
> our template constraints.
>
> Since isRandomAccessRange!R includes isForwardRange!R (which 
> includes isInputRange!R), the compiler should be able to 
> determine that isRandomAccessRange!R is more strict than 
> isInputRange!R.
>
> If anything, you could simply count the && and the ||'s. That 
> is, A && B > B. That ought to be a simple AST+lookup operation. 
> Right?

Template bodies may be arbitrarily complex, and determining 
whether one template predicate implies another is 
halting-equivalent in the general case.

The only way you can do this kind of analysis is if you define, 
in the language spec, a restricted subset of templates to apply 
it to--for example, enum templates whose body consists of a 
single boolean expression.

Personally, I find that kind of special-case handling a bit 
unprincipled, so it wouldn't be my first choice, but it's 
probably the shortest path from where we are now to partial 
ordering for template constraints.


More information about the Digitalmars-d mailing list