Optimizing Immutable and Purity

Walter Bright newshound1 at digitalmars.com
Mon Dec 22 19:56:43 PST 2008


Bill Baxter wrote:
> On Tue, Dec 23, 2008 at 12:10 PM, bearophile <bearophileHUGS at lycos.com> wrote:
>> Walter Bright:
>>> I didn't know gcc had pure functions. It doesn't have immutable data. If
>>> it does optimize with it, you can try it and see!
>> It seems to work:
>> [...]
>> As you can see now there's just one call to bar.
>>
>> Bye,
>> bearophile
>>
> 
> Does GCC complain if you do something clearly impure inside bar?

I got:

     error: attributes are not allowed on a function-definition

Oh well. It looks like a 25% implemented feature. It also only worked 
with g++. gcc wouldn't accept it at all. Without some sort of 
immutability, also, purity cannot be checked anyway.



More information about the Digitalmars-d mailing list