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
> @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
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:
=
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<
>
>
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<
>
>
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
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
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
== 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
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
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
11 matches
Mail list logo