Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 28, 2016 Weak Purity Blog Post | ||||
---|---|---|---|---|
| ||||
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 |
March 28, 2016 Re: Weak Purity Blog Post | ||||
---|---|---|---|---|
| ||||
Posted in reply to sarn | 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.html
Very well-written, someone post it on Reddit.
|
March 28, 2016 Re: Weak Purity Blog Post | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joakim | On Monday, 28 March 2016 at 05:21:36 UTC, Joakim wrote: > 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.html > > Very well-written, someone post it on Reddit. https://www.reddit.com/r/programming/comments/4c8zs6/how_dirtying_pure_functions_a_little_can_be/ |
March 28, 2016 Re: Weak Purity Blog Post | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | On 3/27/2016 10:41 PM, deadalnix wrote:
> On Monday, 28 March 2016 at 05:21:36 UTC, Joakim wrote:
>> 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.html
>>>
>>
>> Very well-written, someone post it on Reddit.
>
> https://www.reddit.com/r/programming/comments/4c8zs6/how_dirtying_pure_functions_a_little_can_be/
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.
|
March 28, 2016 Re: Weak Purity Blog Post | ||||
---|---|---|---|---|
| ||||
Posted in reply to sarn | 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.html
It's a nice article, you should put your name on it as the author!
|
March 28, 2016 Re: Weak Purity Blog Post | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | 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.
|
March 28, 2016 Re: Weak Purity Blog Post | ||||
---|---|---|---|---|
| ||||
Posted in reply to sarn | On 28.03.2016 03:44, sarn wrote: > https://theartofmachinery.com/2016/03/28/dirtying_pure_functions_can_be_useful.html From 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 |
March 30, 2016 Re: Weak Purity Blog Post | ||||
---|---|---|---|---|
| ||||
Posted in reply to ag0aep6g | On Monday, 28 March 2016 at 09:59:12 UTC, ag0aep6g wrote:
> On 28.03.2016 03:44, sarn wrote:
>> https://theartofmachinery.com/2016/03/28/dirtying_pure_functions_can_be_useful.html
>
> From 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
Thanks. I updated the post.
|
March 30, 2016 Re: Weak Purity Blog Post | ||||
---|---|---|---|---|
| ||||
Posted in reply to sarn | 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.html Great. 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 |
March 30, 2016 Re: Weak Purity Blog Post | ||||
---|---|---|---|---|
| ||||
Posted in reply to sarn | 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.html
Nice 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
|
Copyright © 1999-2021 by the D Language Foundation