"Tofu Ninja"  wrote in message news:nwudcquzsuyrrlawx...@forum.dlang.org...

Ok so what is sounds like, is that assert is really what every one claims assume is and enforce is what every one claims assert is...

Does it actually check the condition is true?
theoretical assert: in debug mode
D's assert: in debug mode
assume: no
enforce: always

Does it allow the compiler to remove code using normal control-flow analysis?
theoretical assert: in debug mode
D's assert: always
assume: always
enforce: always

Does it allow the compiler to remove any code that disagrees with the condition? (or is unnecessary when the condition is true?)
theoretical assert: no
D's assert: in release mode
assume: always
enforce: no

Maybe a documentation change on assert is all that is needed, it seems like the docs describe assert as something similar to enforce. Maybe it should be described in a way similar to assume with the added benefit that in non-release modes it will actually check that it is true at runtime. Also if that was changed then the documentation on version(assert) would need changing too.

Yeah, it would probably be a good idea to make it very clear what the compiler is allowed to assume. The current docs are somewhat accurate, but could be more specific. If the 'assume' behaviour is possible with forms other than 'assert(0)' is not specified.

Reply via email to