To help LDC/GDC

Manu turkeyman at gmail.com
Tue Apr 9 00:39:18 PDT 2013


On 9 April 2013 01:07, Jacob Carlborg <doob at me.com> wrote:

> On 2013-04-08 14:52, Iain Buclaw wrote:
>
>> On 8 April 2013 13:25, Jacob Carlborg <doob at me.com <mailto:doob at me.com>>
>>
>> wrote:
>>
>>     On 2013-04-08 10:29, Iain Buclaw wrote:
>>
>>         This information could possibly be helpful.  Though given that
>>         most of
>>         (gdc) codegen is on par with g++, there's probably not much on
>>         the list
>>         that isn't already detected by the backend optimisation passes.
>>
>>
>>     Multiple calls to pure functions could be cached.
>>
>>     --
>>     /Jacob Carlborg
>>
>>
>> Not always, but in some circumstances, yes.
>>
>> ---
>> struct Foo
>> {
>>    int a = 0;
>>    pure int bar (immutable int x)
>>    {
>>      ++a;
>>      return x * 2;
>>    }
>> }
>>
>>
>> void main()
>> {
>>    Foo f;
>>    int i = f.bar(2) + f.bar(2);
>>
>>    assert (i == 8);
>>    assert (f.a == 2);
>> }
>>
>
> I though that wasn't possible. What's the point of pure if that's possible?


Precisely >_<
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130409/df6fd21a/attachment.html>


More information about the Digitalmars-d mailing list