Improve "Improve Contract Syntax" DIP 1009

Ola Fosheim Grøstad ola.fosheim.grostad+dlang at gmail.com
Sat Nov 4 15:46:12 UTC 2017


On Saturday, 4 November 2017 at 15:38:42 UTC, Jonathan M Davis 
wrote:
> In principle, that would be nice, but in practice, it's not 
> really feasible. In the general case, there's no way to save 
> the state of the parameter at the beginning of the function 
> call (you could with some types, but for many types, you 
> couldn't). IIRC, it's been discussed quite a bit in the past, 
> and there are just too many problems with it.

It is obviously possible for a language that has been designed 
for contracts. Whether it is practical is a matter of 
optimization in my view…

Anyway, without having such a focus it makes little sense to say 
that a language supports programming by contracts or pre/post 
conditions. It is more of a syntactical construct in D. Although 
class invariants are still useful in debugging.

C++ is getting pre/post conditions I think. Not sure if it will 
be a plain syntactical construct like in D or something more 
advanced.



More information about the Digitalmars-d mailing list