Re: Map Lambda with Side-Effects

2015-01-15 Thread Nordlöw
On Wednesday, 14 January 2015 at 01:15:57 UTC, Tobias Pankrath wrote: Is it possible to - detect that a lambda is has-side-effects and that - the map hasn't been used? Thing is: I'm regularly doing that on purpose. Could you show me a code example? I'm curious. Actually, isn't your

Re: Map Lambda with Side-Effects

2015-01-13 Thread Tobias Pankrath via Digitalmars-d-learn
Is it possible to - detect that a lambda is has-side-effects and that - the map hasn't been used? Thing is: I'm regularly doing that on purpose. Actually, isn't your closure even weakly pure in your example, because arr is part of the closure and thus an argument to it.

Re: Map Lambda with Side-Effects

2015-01-13 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 13 January 2015 at 10:21:12 UTC, Tobias Pankrath wrote: On Tuesday, 13 January 2015 at 10:06:26 UTC, bearophile wrote: Nordlöw: Has there been any discussions on making map require pure functions now that we have each? Perhaps I'd like Phobos map and filter to be annotated with

Re: Map Lambda with Side-Effects

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 10:06:25 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Nordlöw: Has there been any discussions on making map require pure functions now that we have each? Perhaps I'd like Phobos map and filter to be annotated with pure and to

Re: Map Lambda with Side-Effects

2015-01-13 Thread bearophile via Digitalmars-d-learn
Nordlöw: Has there been any discussions on making map require pure functions now that we have each? Perhaps I'd like Phobos map and filter to be annotated with pure and to have a template constraint that requires their mapping/filtering functions to be strongly pure. Bye, bearophile

Re: Map Lambda with Side-Effects

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 11:26:01 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: ketmar: that will effectively rule out any usage of some global vars or other external state, turning it into either unnecessary mess, or unusable theoretical crap.

Re: Map Lambda with Side-Effects

2015-01-13 Thread Tobias Pankrath via Digitalmars-d-learn
On Tuesday, 13 January 2015 at 10:06:26 UTC, bearophile wrote: Nordlöw: Has there been any discussions on making map require pure functions now that we have each? Perhaps I'd like Phobos map and filter to be annotated with pure and to have a template constraint that requires their

Re: Map Lambda with Side-Effects

2015-01-13 Thread bearophile via Digitalmars-d-learn
ketmar: that will effectively rule out any usage of some global vars or other external state, turning it into either unnecessary mess, or unusable theoretical crap. Unusable theoretical crap is better than the current trap :-) We hare pure in D, but still we have not grown up to actually

Re: Map Lambda with Side-Effects

2015-01-13 Thread Tobias Pankrath via Digitalmars-d-learn
Unusable theoretical crap is better than the current trap :-) We hare pure in D, but still we have not grown up to actually use it in Phobos, for higher order functions, or parallelism. I don't think that Nordlöw presented a serious trap. This might lead to bugs, yes, like anything else, for

Re: Map Lambda with Side-Effects

2015-01-13 Thread bearophile via Digitalmars-d-learn
ketmar: in no way. this just turns Phobos into the same unusable crap, removing the whole sense of having good standard library. If your language has purity, and it doesn't use it where it matters, you have removed its sense of having purity. So if you are right then purity in D is useless

Re: Map Lambda with Side-Effects

2015-01-13 Thread Nordlöw
On Tuesday, 13 January 2015 at 07:35:53 UTC, Nordlöw wrote: Somewhat related to https://github.com/D-Programming-Language/phobos/pull/2024 I wonder about the soundness of `map` in ```D import std.algorithm, std.range, std.stdio; void main(string[] args) { long[] arr; const n = 3;

Map Lambda with Side-Effects

2015-01-12 Thread Nordlöw
Somewhat related to https://github.com/D-Programming-Language/phobos/pull/2024 I wonder about the soundness of `map` in ```D import std.algorithm, std.range, std.stdio; void main(string[] args) { long[] arr; const n = 3; iota(n).map!(a = arr ~= a); writeln(arr);