May 13, 2021
On Thursday, 13 May 2021 at 13:45:50 UTC, Adam D. Ruppe wrote:
> On Thursday, 13 May 2021 at 13:30:29 UTC, Alain De Vos wrote:
>> Or have I a wrong understanding of pure or the compiler.
>
> pure means it doesn't depend on any mutable info outside its arguments.
>
> You are only working on the arguments there so it is ok.

Then D's pure does not match up with WP's definition [1] of pure, at least not

    2. The function application has no side effects (no mutation of local
    static variables, non-local variables, mutable reference arguments
    or input/output streams).

WP quotes Bartosz Milewski:

   2. A function has no side effects. Calling a function once is the same as
   calling it twice and discarding the result of the first call.

[1] https://en.wikipedia.org/wiki/Pure_function
May 13, 2021
On Thursday, 13 May 2021 at 17:48:34 UTC, kdevel wrote:
> Then D's pure does not match up with WP's definition [1] of pure, at least not

Yeah, D's pure is actually useful without being a huge hassle. Makes it into a useful building block that can be used inside other scenarios than the purely pure does.

If you want immutable, that's a separate thing in D. You can use it on its own, or combine it with D pure to get to the full formal pure definition.
May 13, 2021
On Thursday, 13 May 2021 at 17:48:34 UTC, kdevel wrote:
> On Thursday, 13 May 2021 at 13:45:50 UTC, Adam D. Ruppe wrote:
>> On Thursday, 13 May 2021 at 13:30:29 UTC, Alain De Vos wrote:
>>> [...]
>>
>> pure means it doesn't depend on any mutable info outside its arguments.
>>
>> You are only working on the arguments there so it is ok.
>
> Then D's pure does not match up with WP's definition [1] of pure, at least not
>
>     2. The function application has no side effects (no mutation of local
>     static variables, non-local variables, mutable reference arguments
>     or input/output streams).
>
> WP quotes Bartosz Milewski:
>
>    2. A function has no side effects. Calling a function once is the same as
>    calling it twice and discarding the result of the first call.
>
> [1] https://en.wikipedia.org/wiki/Pure_function

Just fyi:
https://dlang.org/articles/safed.html
May 13, 2021
On Thursday, 13 May 2021 at 21:41:48 UTC, Imperatorn wrote:
[...]
>> [1] https://en.wikipedia.org/wiki/Pure_function
>
> Just fyi:
> https://dlang.org/articles/safed.html

Replied to the wrong post?
May 14, 2021
I have the feeling it is a pragmatic definition of pure. (isClose)
Although a compiler message , which does not even be a warning, is always a nice to have.

1 2
Next ›   Last »