A problem with D contracts

Walter Bright newshound2 at digitalmars.com
Sun Aug 1 12:43:02 PDT 2010


bearophile wrote:
> Walter Bright:
>> It is not easier to statically analyze a forall rather than a foreach.
> 
> The problem is that you can put any kind of code inside D contracts, this
> will make them them very to analyse automatically. The restricted semantics
> is a way to avoid this.

All it means is the analysis returns one of three states:

1. yes
2. no
3. couldn't figure it out

This is normal for static analysis. Optimizers use it extensively, for example.


>> I also see no evidence that foreach is more bug-prone than a forall would
>> be.
> 
> I have used Python lazy/eager list comps, and I think they decrease bug-count
> and speed-up coding. In the past I have explained why (mostly because of
> psychological chunking).

Supporting list comprehensions is a separate issue from whether foreach should 
be disallowed in contracts because comps are better.


More information about the Digitalmars-d mailing list