Re: Conditional purity

2014-08-29 Thread Nordlöw
On Sunday, 25 July 2010 at 14:10:10 UTC, Simen kjaeraas wrote: Update: Members of FunctionAttribute have been renamed from uppercase to lowercase and when needed an underscore has been added to the enumerators that conflict with keywords such as: PURE has been renamed to pure_

Re: Conditional purity

2014-08-29 Thread Andrew Godfrey via Digitalmars-d
On Sunday, 25 July 2010 at 14:10:10 UTC, Simen kjaeraas wrote: bearophile bearophileh...@lycos.com wrote: I suggest all people in all D newsgroups, to write code that runs, not uncompilable snippets. All errors in the last Walter's talk can be avoided in few minutes running the code. In

Re: Conditional purity

2010-07-25 Thread Simen kjaeraas
bearophile bearophileh...@lycos.com wrote: But a bigger problem is that I can't see a way to define a conditionally pure templated function, for example a map() that is pure if the given function pointer is pure, and is not pure otherwise: This is fairly simple currently: template map(

Re: Conditional purity

2010-07-25 Thread bearophile
Simen kjaeraas: This is fairly simple currently: template map( alias fn ) { // blah blah blah, whatever is necessary here static if ( isPure!fn ) { pure map( Range )( Range r ) { ... } } else { auto map( Range )( Range r ) { ... } } } Do you mean code

Re: Conditional purity

2010-07-25 Thread Simen kjaeraas
bearophile bearophileh...@lycos.com wrote: Simen kjaeraas: This is fairly simple currently: [snip] Do you mean code like this (this doesn't work yet)? [snip] Yeah. I suggest all people in all D newsgroups, to write code that runs, not uncompilable snippets. All errors in the last

Conditional purity

2010-07-24 Thread bearophile
I think that some years from now, in situations where D will be used used in functional-style programming, the pure attribute for functions will be important and useful. In functional-style programming you often use Higher-Order Functions like map, filter and reduce. So it can be quite