Re: __has_side_effects

2018-04-01 Thread Mark via Digitalmars-d
On Saturday, 31 March 2018 at 20:44:13 UTC, Andrei Alexandrescu wrote: Yah, only strongly pure functions would qualify. Indeed that's easy for the compiler to figure - so I'm thinking pragma(isStronglyPure, expression) would be easy to define. What would be some good uses of this? Andrei

Re: __has_side_effects

2018-04-01 Thread Uknown via Digitalmars-d
On Sunday, 1 April 2018 at 14:33:14 UTC, Andrei Alexandrescu wrote: On 4/1/18 9:39 AM, Uknown wrote: On Sunday, 1 April 2018 at 10:23:40 UTC, Andrei Alexandrescu wrote: On 4/1/18 2:22 AM, Uknown wrote: [...] Terrific, thanks!! Created the PR: https://github.com/dlang/phobos/pull/6403

Re: __has_side_effects

2018-04-01 Thread Andrei Alexandrescu via Digitalmars-d
On 4/1/18 9:39 AM, Uknown wrote: On Sunday, 1 April 2018 at 10:23:40 UTC, Andrei Alexandrescu wrote: On 4/1/18 2:22 AM, Uknown wrote: [...] That's a great initiative, and a worthy trait for the stdlib. I think you'd have an easier time if you reasoned from the other end. A function is

Re: __has_side_effects

2018-04-01 Thread Andrei Alexandrescu via Digitalmars-d
On 4/1/18 9:46 AM, Jonathan M Davis wrote: In principle, a function which has const parameters could be treated as strongly pure if it's given immutable arguments I want to give coders leeway to cheat on that. I'll explain later (allocators).

Re: __has_side_effects

2018-04-01 Thread Jonathan M Davis via Digitalmars-d
On Sunday, April 01, 2018 06:23:40 Andrei Alexandrescu via Digitalmars-d wrote: > On 4/1/18 2:22 AM, Uknown wrote: > > On Sunday, 1 April 2018 at 05:27:38 UTC, Uknown wrote: > >> [...] > >> > >> I knew I was missing something. Fixed it, thanks > >> > >> https://run.dlang.io/is/tZeZrP > > > >

Re: __has_side_effects

2018-04-01 Thread Uknown via Digitalmars-d
On Sunday, 1 April 2018 at 10:23:40 UTC, Andrei Alexandrescu wrote: On 4/1/18 2:22 AM, Uknown wrote: [...] That's a great initiative, and a worthy trait for the stdlib. I think you'd have an easier time if you reasoned from the other end. A function is strongly pure if all of the following

Re: __has_side_effects

2018-04-01 Thread Andrei Alexandrescu via Digitalmars-d
On 4/1/18 2:22 AM, Uknown wrote: On Sunday, 1 April 2018 at 05:27:38 UTC, Uknown wrote: [...] I knew I was missing something. Fixed it, thanks https://run.dlang.io/is/tZeZrP Sorry for the spam, but I also managed to miss `immutable`, `const` and when T has mutable indirections Final

Re: __has_side_effects

2018-04-01 Thread Uknown via Digitalmars-d
On Sunday, 1 April 2018 at 05:27:38 UTC, Uknown wrote: [...] I knew I was missing something. Fixed it, thanks https://run.dlang.io/is/tZeZrP Sorry for the spam, but I also managed to miss `immutable`, `const` and when T has mutable indirections Final version that I'm sure covers all the

Re: __has_side_effects

2018-03-31 Thread Uknown via Digitalmars-d
On Sunday, 1 April 2018 at 04:30:03 UTC, Nicholas Wilson wrote: On Sunday, 1 April 2018 at 04:11:37 UTC, Uknown wrote: On Friday, 30 March 2018 at 20:28:27 UTC, Andrei Alexandrescu wrote: [...] Just for the fun of it, I implemented this as a template: https://run.dlang.io/is/pXLndG You're

Re: __has_side_effects

2018-03-31 Thread Nicholas Wilson via Digitalmars-d
On Sunday, 1 April 2018 at 04:11:37 UTC, Uknown wrote: On Friday, 30 March 2018 at 20:28:27 UTC, Andrei Alexandrescu wrote: https://www.reddit.com/r/programming/comments/88aqsf/the_joy_of_max/ Discussion aside, I notice with pleasant surprise gcc has an introspection primitive we didn't think

Re: __has_side_effects

2018-03-31 Thread Uknown via Digitalmars-d
On Friday, 30 March 2018 at 20:28:27 UTC, Andrei Alexandrescu wrote: https://www.reddit.com/r/programming/comments/88aqsf/the_joy_of_max/ Discussion aside, I notice with pleasant surprise gcc has an introspection primitive we didn't think of: __is_constant that (I assume) yields true if the

Re: __has_side_effects

2018-03-31 Thread Andrei Alexandrescu via Digitalmars-d
On 3/31/18 8:35 PM, Nicholas Wilson wrote: On Saturday, 31 March 2018 at 20:44:13 UTC, Andrei Alexandrescu wrote: Yah, only strongly pure functions would qualify. Indeed that's easy for the compiler to figure - so I'm thinking pragma(isStronglyPure, expression) would be easy to define. What

Re: __has_side_effects

2018-03-31 Thread Nicholas Wilson via Digitalmars-d
On Saturday, 31 March 2018 at 20:44:13 UTC, Andrei Alexandrescu wrote: Yah, only strongly pure functions would qualify. Indeed that's easy for the compiler to figure - so I'm thinking pragma(isStronglyPure, expression) would be easy to define. What would be some good uses of this? Andrei

Re: __has_side_effects

2018-03-31 Thread Andrei Alexandrescu via Digitalmars-d
On 3/31/18 4:01 PM, Simen Kjærås wrote: On Saturday, 31 March 2018 at 19:18:24 UTC, Shachar Shemesh wrote: struct S {   int a;   void func(int b) pure {     // For some strange reason, this is not considered a pure violation.     a+=b;   } } It's the exact equivalent of this code: void

Re: __has_side_effects

2018-03-31 Thread Simen Kjærås via Digitalmars-d
On Saturday, 31 March 2018 at 19:18:24 UTC, Shachar Shemesh wrote: struct S { int a; void func(int b) pure { // For some strange reason, this is not considered a pure violation. a+=b; } } It's the exact equivalent of this code: void func(ref S s, int b) pure { S.a += b; }

Re: __has_side_effects

2018-03-31 Thread Shachar Shemesh via Digitalmars-d
On 30/03/18 23:35, Stefan Koch wrote: On Friday, 30 March 2018 at 20:28:27 UTC, Andrei Alexandrescu wrote: https://www.reddit.com/r/programming/comments/88aqsf/the_joy_of_max/ Discussion aside, I notice with pleasant surprise gcc has an introspection primitive we didn't think of:

Re: __has_side_effects

2018-03-30 Thread Stefan Koch via Digitalmars-d
On Friday, 30 March 2018 at 20:28:27 UTC, Andrei Alexandrescu wrote: https://www.reddit.com/r/programming/comments/88aqsf/the_joy_of_max/ Discussion aside, I notice with pleasant surprise gcc has an introspection primitive we didn't think of: __is_constant that (I assume) yields true if the