digitalmars.D - contracts scope
- Serg Kovrov (17/17) Jan 17 2007 It would be nice to have some sort of 'contracts scope' shared between
- Daniel Keep (17/34) Jan 17 2007 The only thing I can think of is maybe use a private global variable.
It would be nice to have some sort of 'contracts scope' shared between `in` and `out`. I'm looking a way to implement something like this: ubyte[] foo(ubyte[] src, inout ubyte[] dst) in { auto ptr = dst.ptr; } out { if (ptr != dst.ptr) wtitefln("dst reallocated"); } body { .... -- serg.
Jan 17 2007
Serg Kovrov wrote:It would be nice to have some sort of 'contracts scope' shared between `in` and `out`. I'm looking a way to implement something like this: ubyte[] foo(ubyte[] src, inout ubyte[] dst) in { auto ptr = dst.ptr; } out { if (ptr != dst.ptr) wtitefln("dst reallocated"); } body { ....The only thing I can think of is maybe use a private global variable. private ubyte[] _foo_ptr; ubyte[] foo(ubyte[] src, inout ubyte[] dst) in { _foo_ptr = dst.ptr; } out { if (_foo_ptr != dst.ptr) writefln("dst reallocated"); } body { .... Not an ideal solution, and it's not thread-safe, but should be OK. -- Daniel
Jan 17 2007