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
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)
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
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);
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
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 ...)
{
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