Re: Pure higher order functions

2011-07-10 Thread bearophile
Daniel Murphy: > function shouldn't be required once > http://d.puremagic.com/issues/show_bug.cgi?id=3235 is fixed. OK. > > 3827 automatic joining of adjacent strings is bad [partial patch present] > The patch for this seems solid, I might make a pull for it after the > release. Is a good en

Re: Pure higher order functions

2011-07-09 Thread Daniel Murphy
"bearophile" wrote in message news:iva7iv$b6v$1...@digitalmars.com... >> Still, it should make construction of immutable structures without >> casting a lot easier. > > I presume you mean something like this ("function" is currently required > if you want to add "pure" too): > Or use a nested f

Re: Pure higher order functions

2011-07-09 Thread bearophile
Daniel Murphy: > Only for strongly pure functions - not const pure at this point. I see, OK. > Still, it should make construction of immutable structures without casting a > lot easier. I presume you mean something like this ("function" is currently required if you want to add "pure" too):

Re: Pure higher order functions

2011-07-09 Thread Daniel Murphy
"bearophile" wrote in message news:iv9grs$286j$1...@digitalmars.com... >> Seeing the recent large amount of pull requests I am seeing, is someone >> willing to implement this type system feature? > > yebblies delivers, quickly too :-) > http://d.puremagic.com/issues/show_bug.cgi?id=5081 > https:

Re: Pure higher order functions

2011-07-09 Thread bearophile
> Seeing the recent large amount of pull requests I am seeing, is someone > willing to implement this type system feature? yebblies delivers, quickly too :-) http://d.puremagic.com/issues/show_bug.cgi?id=5081 https://github.com/D-Programming-Language/dmd/pull/218 At this rhythm of improvements D

Re: Pure higher order functions

2011-07-08 Thread bearophile
Jonathan M Davis: > Regardless, the overall situation with purity is improving. I agree. Someday I hope to see another little improvement in the D type system, to allow code like this to compile without the need of a cast of s2 to string at the end: string foo(in string s) pure nothrow { // st

Re: Pure higher order functions

2011-07-07 Thread Jonathan M Davis
On 2011-07-07 15:19, bearophile wrote: > KennyTM~: > > On Jul 8, 11 00:43, KennyTM~ wrote: > > > No, I think it's a bug in pure-inference. > > > > > > pure int h() { > > > > > > return 1; > > > > > > } > > > int f(alias g)() { > > > > > > return g(); > > > > > > } > > > pure int i() { > > > >

Re: Pure higher order functions

2011-07-07 Thread bearophile
KennyTM~: > On Jul 8, 11 00:43, KennyTM~ wrote: > > No, I think it's a bug in pure-inference. > > > > pure int h() { > > return 1; > > } > > int f(alias g)() { > > return g(); > > } > > pure int i() { > > return f!h(); // pure function 'i' cannot call impure function 'f' > > } > >

Re: Pure higher order functions

2011-07-07 Thread KennyTM~
On Jul 8, 11 00:43, KennyTM~ wrote: No, I think it's a bug in pure-inference. pure int h() { return 1; } int f(alias g)() { return g(); } pure int i() { return f!h(); // pure function 'i' cannot call impure function 'f' } http://d.puremagic.com/issues/show_bug.cgi?id=6265

Re: Pure higher order functions

2011-07-07 Thread Jonathan M Davis
On 2011-07-07 04:34, bearophile wrote: > With the latest beta update this compiles: > > > @property bool empty(T)(in T[] a) pure nothrow { > return !a.length; > } > > @property ref T front(T)(T[] a) pure nothrow { > assert(a.length); > return a[0]; > } > > void popFront(A)(ref A a) pure nothrow

Re: Pure higher order functions

2011-07-07 Thread KennyTM~
On Jul 7, 11 19:34, bearophile wrote: With the latest beta update this compiles: @property bool empty(T)(in T[] a) pure nothrow { return !a.length; } @property ref T front(T)(T[] a) pure nothrow { assert(a.length); return a[0]; } void popFront(A)(ref A a) pure nothrow { as

Re: Pure higher order functions

2011-07-07 Thread bearophile
With the latest beta update this compiles: @property bool empty(T)(in T[] a) pure nothrow { return !a.length; } @property ref T front(T)(T[] a) pure nothrow { assert(a.length); return a[0]; } void popFront(A)(ref A a) pure nothrow { assert(a.length); a = a[1 .. $]; } struct

Re: Pure higher order functions

2011-07-06 Thread KennyTM~
On Jul 7, 11 10:02, bearophile wrote: Jonathan M Davis: I don't think that it makes any sense to talk about a pure struct or class. Functions are pure, not types.< In my opinion, if D wants to solve the issue of pure HOFs, then it has to decide (or invent) what a pure struct (instance, if y

Re: Pure higher order functions

2011-07-06 Thread bearophile
Jonathan M Davis: >I don't think that it makes any sense to talk about a pure struct or class. >Functions are pure, not types.< In my opinion, if D wants to solve the issue of pure HOFs, then it has to decide (or invent) what a pure struct (instance, if you want) is. Bye, bearophile

Re: Pure higher order functions

2011-07-06 Thread Jonathan M Davis
On 2011-07-06 16:19, bearophile wrote: > Jonathan M Davis: > > I believe that the problem here is essentially what's being argued over > > in the dmd-beta list right now. > > In D a HOF is implemented with a struct or a class. So, what's a pure > struct/class, generally? I don't think that it mak

Re: Pure higher order functions

2011-07-06 Thread bearophile
Jonathan M Davis: > I believe that the problem here is essentially what's being argued over > in the dmd-beta list right now. In D a HOF is implemented with a struct or a class. So, what's a pure struct/class, generally? Bye, bearophile

Re: Pure higher order functions

2011-07-06 Thread Jonathan M Davis
On 2011-07-06 15:42, bearophile wrote: > I think D eventually needs to allow the creation of pure higher order > functions, like map, filter, amap (that means array(map(...))). > > > DMD 2.054beta improves the situation with the automatic inference for pure > and nothrow. >

Pure higher order functions

2011-07-06 Thread bearophile
I think D eventually needs to allow the creation of pure higher order functions, like map, filter, amap (that means array(map(...))). DMD 2.054beta improves the situation with the automatic inference for pure and nothrow. (By the way, the changelog says "Add warning about calling pure no