Managing memory usage at Compile Time with DMD

John Colvin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 9 04:05:19 PDT 2015


On Thursday, 9 April 2015 at 10:23:06 UTC, wobbles wrote:
> On Thursday, 9 April 2015 at 10:04:09 UTC, John Colvin wrote:
>> On Thursday, 9 April 2015 at 09:49:39 UTC, wobbles wrote:
>>> Another possibilty I was looking at was to write a tool that 
>>> will spit out all combinations at runtime, and then import 
>>> these back into the bot at compile time to build a lookup 
>>> table that way.
>>>
>>> Thanks!
>>
>> This is definitely a better idea. I would probably load them 
>> at runtime instead, it scales better.
>
> But if the compiler knows about all the values at compile time, 
> it will be able to optimise things better than at runtime?

Well, it depends. Sometimes it makes a big difference, other 
times there's not much, if any, advantage. The only way to reason 
about it is to look at your code and think about what the 
compiler might be able to do given certain information, then 
check the asm to see if it's actually doing it.


More information about the Digitalmars-d-learn mailing list