Re: We need a way to make functions pure and/or nothrow based on the

2010-11-14 Thread bearophile
Jonathan M Davis: >The one problem I see is that if the compiler has to determine whether a given >function can be pure and/or nothrow, it's going to potentially have to go >arbitrarily deep into the call hierarchy to figure it out< This is already done for pure functions, const, immutable, not

Re: We need a way to make functions pure and/or nothrow based on the

2010-11-14 Thread bearophile
> @optional_tag(isPure!F, pure) int[] map(F)(F f, int[] data) { > int[] res; > foreach (x; data) > res ~= f(x); > return res; > } This may not suffice to correctly tell apart strong pure functions from weak pure ones... Bye, bearophile

Re: We need a way to make functions pure and/or nothrow based on the

2010-11-14 Thread Jérôme M. Berger
bearophile wrote: >> @optional_tag(isPure!F, pure) int[] map(F)(F f, int[] data) { >> int[] res; >> foreach (x; data) >> res ~= f(x); >> return res; >> } > > This may not suffice to correctly tell apart strong pure functions from weak > pure ones... > Untested: =

Re: We need a way to make functions pure and/or nothrow based on the

2010-11-14 Thread Jonathan M Davis
On Sunday 14 November 2010 04:26:56 bearophile wrote: > Jonathan M Davis: > >The one problem I see is that if the compiler has to determine whether a > >given function can be pure and/or nothrow, it's going to potentially have > >to go arbitrarily deep into the call hierarchy to figure it out< > >

Re: We need a way to make functions pure and/or nothrow based on the

2010-11-14 Thread Jonathan M Davis
On Sunday 14 November 2010 04:26:56 bearophile wrote: > Jonathan M Davis: > >The one problem I see is that if the compiler has to determine whether a > >given function can be pure and/or nothrow, it's going to potentially have > >to go arbitrarily deep into the call hierarchy to figure it out< > >

Re: We need a way to make functions pure and/or nothrow based on the

2010-11-14 Thread bearophile
Jonathan M Davis: > So, checking the purity of a single function isn't going to do it (which > appears to > be what your @optional_tag is doing). The first argument of @optional_tag is a compile-time boolean, so you may test all the functions you want (this reminds me Java checked exceptions a

We need a way to make functions pure and/or nothrow based on the purity and/or nothrowability of the functions that they call

2010-11-14 Thread Jonathan M Davis
That is, there are plenty of cases where template code may or may not be able to pure or nothrow and that whether it can or not depends on what it's templatized on. For instance, if you had a range which iterated over a range of characters in some manner (other than simply iterating over it as

Re: We need a way to make functions pure and/or nothrow based on the purity and/or nothrowability of the functions that they call

2010-11-14 Thread Philippe Sigaud
On Sun, Nov 14, 2010 at 10:56, Jonathan M Davis wrote: > Does anyone have some good suggestions on how to solve this issue? IIRC, I posted something related to this 2-3 months ago, though I don't know if that was a real solution. That was for pure only, but that could be extended to pure¬hrow. Th

Re: We need a way to make functions pure and/or nothrow based on the purity and/or nothrowability of the functions that they call

2010-11-14 Thread Tomasz Sowiński
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article > [snip] > We really need to add a way to have a function marked as nothrow and/or pure > based on whether the functions that it calls are nothrow and/or pure. Whether > that should require listing the functions that need to be pure and

Re: We need a way to make functions pure and/or nothrow based on the purity and/or nothrowability of the functions that they call

2010-11-14 Thread Jonathan M Davis
On Sunday 14 November 2010 07:07:11 Philippe Sigaud wrote: > On Sun, Nov 14, 2010 at 10:56, Jonathan M Davis wrote: > > Does anyone have some good suggestions on how to solve this issue? > > IIRC, I posted something related to this 2-3 months ago, though I > don't know if that was a real solution

Re: We need a way to make functions pure and/or nothrow based on the purity and/or nothrowability of the functions that they call

2010-11-14 Thread Jonathan M Davis
On Sunday 14 November 2010 07:18:24 Tomasz Sowiński wrote: > == Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article > > > [snip] > > We really need to add a way to have a function marked as nothrow and/or > > pure based on whether the functions that it calls are nothrow and/or > > pure. Wh