Pure functions in D

Bruno Medeiros brunodomedeiros+spam at com.gmail
Fri Oct 3 04:47:39 PDT 2008


Walter Bright wrote:
> Bruno Medeiros wrote:
> 
>>  >Pure functions can be executed asynchronously.
>> Do you realistically expect the compiler to be able to determine on 
>> its own when it is worthwhile to perform such asynchronous call? Will 
>> it be okay for the compiler to create and destroy threads under the 
>> hood, without programmer intervention?
> 
> If threads/cores get cheap enough, I think this can be done. In the 
> meantime, pure functions make great arguments to 'futures' calls.

What if a function is pure but memory expensive? Say we are in loop, and 
the compiler spawns, say, 8 threads to run that function 
asynchronously... that could increase the program's memory consumption 8 
fold, all under the hood.

-- 
Bruno Medeiros - Software Developer, MSc. in CS/E graduate
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list