Contracts for delegates

Dmitry Olshansky dmitry.olsh at gmail.com
Tue Jan 8 06:23:08 PST 2013


08-Jan-2013 17:58, bearophile пишет:
> Benjamin Thaut:
>
>> I don't think that this is possible at all.
>
> I see.
>
>
>> Do you think this is usefull?
>
> In a program I define a null delegate, then later I assign to it one of
> different functions according to some run time values, and later I call
> the delegate several times. In such situation a delegate is handy to
> shorten my code, where max performance is not needed.
>
> I generally use contract programming, because I've seen it catches some
> of my coding mistakes. So what's
wrong in desiring to add a
> pre-condition to that delegate?

Then it has to be part of the type (a meta-info bound to it)... how 
would you then check if 2 functions have equivalent (but with different 
code) preconditions?

  (Currently I have put the pre-condition
> asserts inside the function assigned to the delegate).

Where it truly belongs.

>
> Bye,
> bearophile


-- 
Dmitry Olshansky


More information about the Digitalmars-d-learn mailing list