[Issue 6857] Precondition contract checks should be statically bound.

Walter Bright newshound2 at digitalmars.com
Sun May 6 02:29:08 PDT 2012


On 5/6/2012 2:19 AM, d-bugmail at puremagic.com wrote:
> That is not this complicated. you need a final function that check the in
> contract, then call another virtual function that actually execute the function
> body and the out contract.
>
> With such a configuration, the in contract is checked and only then the virtual
> dispatch is done.


It's not that simple. Several considerations have to be met:

1. Because of struct construction/destruction, you really only want to construct 
the parameter list *once*, but you're calling two functions with the same 
parameter list.

2. Variadic functions mean that one function cannot forward to another one using 
standard functions. (Perhaps a dirty magic thunk can work.)

3. The presence or absence of contracts must not change the ABI of the function.

4. The virtual table must be unchanged.

5. It's not so practical to jump into the middle of another function - things 
just aren't designed that way.

6. The caller now has to be aware of contracts in the called function, this was 
never necessary before.


More information about the Digitalmars-d-bugs mailing list