Do pure functions solve the "return const" problems?

Christopher Wright dhasenan at gmail.com
Thu Apr 10 05:55:43 PDT 2008


Janice Caron wrote:
> On 10/04/2008, Christopher Wright <dhasenan at gmail.com> wrote:
>>  But you seem to be saying that, if you remove 'pure' from all those
>> functions, the result will be undefined. Is this the case?
> 
> The order of evaluation is undefined. The result depends on the order
> of evaluation. In fact, according to the D docs, it's even possible
> for the same function to give different results depending on whether
> it's evaluated at compile-time or run-time, if you rely on "dependency
> on implementation defined order of evaluation".

So you're saying that undefined behavior won't magically become defined 
with pure, so the feature that can cause undefined behavior should not 
be allowed with pure.

Why? Why wouldn't that merely be undefined behavior when you add pure?



More information about the Digitalmars-d mailing list