Re: Lazy variadic not working, any alternatives?

2015-05-26 Thread Tofu Ninja via Digitalmars-d-learn
On Tuesday, 26 May 2015 at 05:54:11 UTC, John Colvin wrote: Something like this appears to work: import std.typetuple : allSatisfy; enum implicityConvertibleToBool(T) = is(T : bool); bool tok_and(Args...)(lazy Args terms) if(allSatisfy!(implicitlyConvertibleToBool, Args)) { auto

Re: Lazy variadic not working, any alternatives?

2015-05-26 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 26 May 2015 at 06:04:59 UTC, Tofu Ninja wrote: On Tuesday, 26 May 2015 at 05:54:11 UTC, John Colvin wrote: Something like this appears to work: import std.typetuple : allSatisfy; enum implicityConvertibleToBool(T) = is(T : bool); bool tok_and(Args...)(lazy Args terms)

Re: Lazy variadic not working, any alternatives?

2015-05-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/25/15 11:53 PM, Tofu Ninja wrote: On Tuesday, 26 May 2015 at 05:43:59 UTC, Tofu Ninja wrote: On Tuesday, 26 May 2015 at 05:22:26 UTC, Tofu Ninja wrote: Actually the code seems to compile on 2.067.1 but definitely does not work as expected. ... I guess it stems from the fact that its lazy

Re: Lazy variadic not working, any alternatives?

2015-05-25 Thread Tofu Ninja via Digitalmars-d-learn
On Tuesday, 26 May 2015 at 05:22:26 UTC, Tofu Ninja wrote: Actually the code seems to compile on 2.067.1 but definitely does not work as expected. Another example of Lazy variadic to show how it works... void main(string[] args) { test(a(), b(), c()); } bool a() { writeln(a);

Re: Lazy variadic not working, any alternatives?

2015-05-25 Thread Tofu Ninja via Digitalmars-d-learn
On Tuesday, 26 May 2015 at 05:43:59 UTC, Tofu Ninja wrote: On Tuesday, 26 May 2015 at 05:22:26 UTC, Tofu Ninja wrote: Actually the code seems to compile on 2.067.1 but definitely does not work as expected. ... I guess it stems from the fact that its lazy (bool[]) Wish I could do (lazy

Re: Lazy variadic not working, any alternatives?

2015-05-25 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 26 May 2015 at 05:22:26 UTC, Tofu Ninja wrote: So I was writing a simple parser and I wanted a functionality that was basically try list of tokens in order and if any of them fail, rewind input. I tried using a lazy variadic function: bool tok_and(lazy bool[] terms ...) {

Lazy variadic not working, any alternatives?

2015-05-25 Thread Tofu Ninja via Digitalmars-d-learn
So I was writing a simple parser and I wanted a functionality that was basically try list of tokens in order and if any of them fail, rewind input. I tried using a lazy variadic function: bool tok_and(lazy bool[] terms ...) { auto backup = getInputLocation(); for(int i = 0; i