Imagine you want an image to keep the width of 512:
void func(Image img) {
assert(img.width == 512);
img.doSomething();
assert(img.width == 512);
while (img.somethingElse()) {
assert(img.width == 512)
someFunc(img);
assert(img.width == 512);
}
}
In
On 10/07/2012 11:44 AM, Henning Pohl wrote:
Imagine you want an image to keep the width of 512:
void func(Image img) {
assert(img.width == 512);
img.doSomething();
assert(img.width == 512);
while (img.somethingElse()) {
assert(img.width == 512)
someFunc(img);
assert(img.width == 512);
}
}
In
On Sunday, 7 October 2012 at 20:18:15 UTC, Ali Çehreli wrote:
Sounds good.
Thanks.
You haven't mentioned the invariant keyword, so perhaps you are
not aware of that feature?
http://dlang.org/class.html#Invariant
http://dlang.org/dbc.html
Although the docs seem to favor classes, invaria
On Sunday, 7 October 2012 at 20:46:09 UTC, Henning Pohl wrote:
On Sunday, 7 October 2012 at 20:18:15 UTC, Ali Çehreli wrote:
Sounds good.
Thanks.
You haven't mentioned the invariant keyword, so perhaps you
are not aware of that feature?
http://dlang.org/class.html#Invariant
http://dlang.
On Monday, 8 October 2012 at 08:53:39 UTC, simendsjo wrote:
You can create a wrapper struct that includes an invariant:
import std.stdio;
struct Image
{
int width;
void doSomething()
{
}
void modifiesWidth()
{
--width;
}
}
void func(Image img)
{
struct
I just thought it's really cool how D makes this possible and very
easy to do. Check it out:
http://codepad.org/yA8ju9u0
I was thinking of using something like this in code samples for a
library (e.g. CairoD), where a Recorder object like this would capture
the states of some shape and then gener
On Sat, 01 Oct 2011 17:47:10 +0200, Andrej Mitrovic
wrote:
I just thought it's really cool how D makes this possible and very
easy to do. Check it out:
http://codepad.org/yA8ju9u0
I was thinking of using something like this in code samples for a
library (e.g. CairoD), where a Recorder objec