April 24, 2013 Re: D compile time algorithms implementation | ||||
---|---|---|---|---|
| ||||
Posted in reply to khurshid | > But,
> I'm sorry, I do not have the ability to work with the code
> itself, now.
> I take a few other things.
>
> Regards,
> Khursid.
Oh,god !!!
|
April 24, 2013 Re: D compile time algorithms implementation | ||||
---|---|---|---|---|
| ||||
Posted in reply to khurshid | Is this code right? template templateAnd(Preds...) { template templateAnd(T...) { static if (Preds.length == 0) { enum templateAnd = true; } else static if (Preds.length == 1) { enum templateAnd = Instantiate!(Preds[0],T); } else { static if (Instantiate!(.templateAnd(Preds[0..$/2]),T)) { enum templateAnd = Instantiate!(.templateAnd(Preds[$/2..$]),T); } else { enum templateAnd = false; } } } } here template Instantiate(alias P, T...) { alias Instantiate = P!(T); } |
April 24, 2013 Re: D compile time algorithms implementation | ||||
---|---|---|---|---|
| ||||
Posted in reply to khurshid | On Wednesday, 24 April 2013 at 08:46:03 UTC, khurshid wrote:
> Is this code right?
>
>
> template templateAnd(Preds...)
> { … }
No. templateAnd/templateOr are documented to perform short-circuit evaluation of the operands.
David
|
April 24, 2013 Re: D compile time algorithms implementation | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Nadlinger | On 04/24/2013 09:28 PM, David Nadlinger wrote:
> On Wednesday, 24 April 2013 at 08:46:03 UTC, khurshid wrote:
>> Is this code right?
>>
>>
>> template templateAnd(Preds...)
>> { … }
>
> No. templateAnd/templateOr are documented to perform short-circuit
> evaluation of the operands.
>
> David
I think that is what the implementation intends to do. I am more worried about the expressions reading similar to:
.templateAnd(Preds[0..$/2])
The code appears to be entirely untested.
|
April 24, 2013 Re: D compile time algorithms implementation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | On 04/24/2013 10:28 PM, Timon Gehr wrote:
> On 04/24/2013 09:28 PM, David Nadlinger wrote:
>> On Wednesday, 24 April 2013 at 08:46:03 UTC, khurshid wrote:
>>> Is this code right?
>>>
>>>
>>> template templateAnd(Preds...)
>>> { … }
>>
>> No. templateAnd/templateOr are documented to perform short-circuit
>> evaluation of the operands.
>>
>> David
>
> I think that is what the implementation intends to do. I am more worried
> about the expressions reading similar to:
>
> .templateAnd(Preds[0..$/2])
>
> The code appears to be entirely untested.
(Also, the lookup rules have been changed for function calls and template instantiations on eponymous template symbols, and therefore the '.' prefix is not needed anymore.)
|
April 25, 2013 Re: D compile time algorithms implementation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | I am newbie D language. Only, I am playing with meta programming. I have a question. Using D language futures, could to implement NoDuplicates meta algorithm with O(N) time, or though O(N ln(N) )? |
April 25, 2013 Re: D compile time algorithms implementation | ||||
---|---|---|---|---|
| ||||
Posted in reply to khurshid | And, what to you're saying about that, MostDerived implementation? http://d.puremagic.com/issues/show_bug.cgi?id=9976 |
Copyright © 1999-2021 by the D Language Foundation