assume, assert, enforce, @safe

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Sat Aug 2 09:12:41 PDT 2014


"bearophile"  wrote in message news:hnbybyssdlwaomescwvg at forum.dlang.org...

> I like compile-time tests, you can see it from several of my last posts, 
> but:
> 1) It's better to be able to express general tests using CTFE, instead of 
> covering a limited but growing list of cases. The general solution needs 
> only half page of text to be explained in a next version of the TDPL, 
> while your proposal will need a growing list of cases;

This doesn't need a lot of text to explain either: "when possible, the 
compiler will check preconditions at compile time"

> 2) For reasons Walter has explained elsewhere, those tests need to be 
> explicit, even syntactically-wise (and Walter has a strong opinion on 
> this, so it's unlikely you will change his mind. And I agree with him on 
> this).

I'm really only interested in Walter's opinion when it's coming from Walter. 
I've responded to Walter's objections and we'll see where that goes.

> So far I've seen only one proposal to do this (the Enum Preconditions), 
> and it too has some limits (caused by compilation units, that can be 
> removed turning the Enum Preconditions into things handled like 
> templates).

I feel like you're confusing this pull request with another enhancement. 
The discussion should be about whether this exact feature is worthwhile, not 
if some other feature would solve some other problems.  Do you really think 
the compiler opportunistically checking preconditions would be a bad thing 
for D? 



More information about the Digitalmars-d mailing list