Pure functions in D

Bruno Medeiros brunodomedeiros+spam at com.gmail
Tue Sep 23 15:01:40 PDT 2008


Walter Bright wrote:
> http://www.reddit.com/r/programming/comments/72r6q/walter_bright_pure_functions_in_d/ 
> 

Interesting.

 >Parameters to a pure function can be mutable, but calls cannot be 
cached or executed asynchronously if the arguments contain any 
references to mutable data.

Cool, this amounts the same to the "partial pure"/"contextually pure" 
idea Don and I discussed some time ago. Good to see you thought of the same.

A few questions:

If a pure function can throw, is it required that it always throws given 
the same inputs (and throwing the same Exception?).

Will memory allocation be considered pure?

 >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?


-- 
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