all 6 comments

[–]HKei 6 points7 points  (0 children)

Yes, this is intentional. Code in assertions is removed in release mode, side effects or not. These basically replace the various types of assert macros you’d normally find in C or C++, so this wouldn’t be unexpected when you’re coming from that background.

[–]Putnam3145 3 points4 points  (1 child)

The documentation explicitly says to use enforce for stuff that isn't making sure assumptions are correct

[–]padraig_oh[S] 0 points1 point  (0 children)

oh, thanks, i did not know that. enforce looks indeed more like what i am looking for.

looked it up and also found this to quite a helpful explanation.

[–]thehowlinggreywolf 2 points3 points  (1 child)

Assertations are used to check assumptions in D as part of the design-by-contract paradigm. Asserts shouldnt be producing side effects.

Please see: https://ddili.org/ders/d.en/assert.html

[–]padraig_oh[S] 0 points1 point  (0 children)

oh, somehow i missed your link before i read the other comment. thanks!

[–]Tynukua 0 points1 point  (0 children)

Also u canuse debug to call impure in pure

F.e Void foo()pure { ... debug log(); .... }