digitalmars.D.announce - Weak Purity Blog Post
- sarn (6/6) Mar 27 2016 D's implementation of functional purity supports "weak" purity -
- Joakim (2/8) Mar 27 2016 Very well-written, someone post it on Reddit.
- deadalnix (2/12) Mar 27 2016 https://www.reddit.com/r/programming/comments/4c8zs6/how_dirtying_pure_f...
- Walter Bright (7/19) Mar 28 2016 Queue my usual harangue:
- Walter Bright (2/3) Mar 28 2016 BTW, thanks for posting it.
- Walter Bright (2/6) Mar 28 2016 It's a nice article, you should put your name on it as the author!
- ag0aep6g (5/7) Mar 28 2016 Indirections in the return type also play into this. David Nadlinger
- sarn (2/10) Mar 29 2016 Thanks. I updated the post.
- =?UTF-8?B?Tm9yZGzDtnc=?= (8/11) Mar 30 2016 Great. It would be nice if you added a section that discusses
- Jon D (9/15) Mar 30 2016 Nice article. A suggestion: The point about improved testability
- sarn (9/9) Mar 30 2016 Yeah, there's a lot more stuff I could have talked about, but I
D's implementation of functional purity supports "weak" purity - functions that can mutate arguments but are otherwise traditionally pure. I wrote a post about some of the practical benefits of this kind of purity: https://theartofmachinery.com/2016/03/28/dirtying_pure_functions_can_be_useful.html
Mar 27 2016
On Monday, 28 March 2016 at 01:44:02 UTC, sarn wrote:D's implementation of functional purity supports "weak" purity - functions that can mutate arguments but are otherwise traditionally pure. I wrote a post about some of the practical benefits of this kind of purity: https://theartofmachinery.com/2016/03/28/dirtying_pure_functions_can_be_useful.htmlVery well-written, someone post it on Reddit.
Mar 27 2016
On Monday, 28 March 2016 at 05:21:36 UTC, Joakim wrote:On Monday, 28 March 2016 at 01:44:02 UTC, sarn wrote:https://www.reddit.com/r/programming/comments/4c8zs6/how_dirtying_pure_functions_a_little_can_be/D's implementation of functional purity supports "weak" purity - functions that can mutate arguments but are otherwise traditionally pure. I wrote a post about some of the practical benefits of this kind of purity: https://theartofmachinery.com/2016/03/28/dirtying_pure_functions_can_be_useful.htmlVery well-written, someone post it on Reddit.
Mar 27 2016
On 3/27/2016 10:41 PM, deadalnix wrote:On Monday, 28 March 2016 at 05:21:36 UTC, Joakim wrote:Queue my usual harangue: Articles do MUCH MUCH better on reddit if, when posted, a brief description of the content of the article is also posted. Like what sarn posted here. Not doing so seriously blunts the value. People need a reason to click on the article. It's why when you google something, you don't just get a list of links. You get a blurb with each link.On Monday, 28 March 2016 at 01:44:02 UTC, sarn wrote:https://www.reddit.com/r/programming/comments/4c8zs6/how_dirtying_pure_functions_a_little_can_be/D's implementation of functional purity supports "weak" purity - functions that can mutate arguments but are otherwise traditionally pure. I wrote a post about some of the practical benefits of this kind of purity: https://theartofmachinery.com/2016/03/28/dirtying_pure_functions_can_be_useful.htmlVery well-written, someone post it on Reddit.
Mar 28 2016
On 3/27/2016 10:41 PM, deadalnix wrote:https://www.reddit.com/r/programming/comments/4c8zs6/how_dirtying_pure_functions_a_little_can_be/BTW, thanks for posting it.
Mar 28 2016
On 3/27/2016 6:44 PM, sarn wrote:D's implementation of functional purity supports "weak" purity - functions that can mutate arguments but are otherwise traditionally pure. I wrote a post about some of the practical benefits of this kind of purity: https://theartofmachinery.com/2016/03/28/dirtying_pure_functions_can_be_useful.htmlIt's a nice article, you should put your name on it as the author!
Mar 28 2016
On 28.03.2016 03:44, sarn wrote:https://theartofmachinery.com/2016/03/28/dirtying_pure_functions_can_be_useful.htmlFrom there:Well, you can get the usual (“strong”) purity guarantee just by making all pointer or reference type arguments const.Indirections in the return type also play into this. David Nadlinger explains this in his article on the matter: http://klickverbot.at/blog/2012/05/purity-in-d/#indirections-in-the-return-type
Mar 28 2016
On Monday, 28 March 2016 at 09:59:12 UTC, ag0aep6g wrote:On 28.03.2016 03:44, sarn wrote:Thanks. I updated the post.https://theartofmachinery.com/2016/03/28/dirtying_pure_functions_can_be_useful.htmlFrom there:Well, you can get the usual (“strong”) purity guarantee just by making all pointer or reference type arguments const.Indirections in the return type also play into this. David Nadlinger explains this in his article on the matter: http://klickverbot.at/blog/2012/05/purity-in-d/#indirections-in-the-return-type
Mar 29 2016
On Monday, 28 March 2016 at 01:44:02 UTC, sarn wrote:I wrote a post about some of the practical benefits of this kind of purity: https://theartofmachinery.com/2016/03/28/dirtying_pure_functions_can_be_useful.htmlGreat. It would be nice if you added a section that discusses purity in collaboration with allocators. See discussions: http://forum.dlang.org/post/yvwtjybwphxovrxavdiw forum.dlang.org http://forum.dlang.org/post/ejaarbdzcqgqhkxladoz forum.dlang.org and https://github.com/D-Programming-Language/druntime/pull/1183#issuecomment-202444315
Mar 30 2016
On Monday, 28 March 2016 at 01:44:02 UTC, sarn wrote:D's implementation of functional purity supports "weak" purity - functions that can mutate arguments but are otherwise traditionally pure. I wrote a post about some of the practical benefits of this kind of purity: https://theartofmachinery.com/2016/03/28/dirtying_pure_functions_can_be_useful.htmlNice article. A suggestion: The point about improved testability when designing for purity is well made. In D, this is further supported by the ability to write and place unit tests alongside the functions themselves. That's my personal opinion at least - because unit test are so easy to write in D, it encourages design for testability. My suggestion is to add a note about this to the post. --Jon
Mar 30 2016
Yeah, there's a lot more stuff I could have talked about, but I think I'll leave it for other posts. About testing, I think the way protection works in D (i.e., private members are accessible within the same file) is important, too. I was a bit suspicious of that feature when I first looked at D (coming from C++) but now I actually like the kind of project structure it leads to. I think better testability is just one of the advantages, but I'll write up a full blog post sometime.
Mar 30 2016