If you could make any changes to D, what would they look like?

Dukc ajieskola at gmail.com
Wed Oct 27 19:19:31 UTC 2021

On Monday, 25 October 2021 at 14:34:24 UTC, IGotD- wrote:
>> - pure
> Agreed, if you don't want a function messing around with a 
> global state, don't mess around with a global state, easy. You 
> don't need a badge for that. I'm sure there are holes in the 
> pure rule that the compiler cannot detect as well.

`pure` is also supposed to be an optimization aid. I was about to 
say that you're right about that holes thing, because of stuff 
like this one:

pure short coming()
{ typeof(return) result = void;
   return result; //may return anything

But when you think of it, why should this be a problem? This one 
returns an implementation defined value. If a compiler skips 
repeated calls to this one because of the `pure` attribute and 
just reuses the value from the first call, so what? Because the 
return values are implementation defined, the compiler is free to 
have them all to be the same with regards to each other.

More information about the Digitalmars-d mailing list