Contracts for delegates

Benjamin Thaut code at benjamin-thaut.de
Tue Jan 8 05:35:41 PST 2013


Am 08.01.2013 12:14, schrieb bearophile:
> How do you add contracts to delegates?
>
> This doesn't work:
>
>
> void main() {
>      void delegate(int) foo;
>
>      foo = (x)
>      in {
>          assert(x > 0);
>      } body {
>      };
> }
>
>
> Nor this:
>
>
> void main() {
>      void delegate(int) foo
>      in {
>          assert(x > 0);
>      };
>
>      foo = (x) {};
> }
>
> Bye,
> bearophile

I don't think that this is possible at all. Do you think this is usefull?

Kind Regards
Benjamin Thaut


More information about the Digitalmars-d-learn mailing list