www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Issue with Curry

reply sybrandy <sybrandy gmail.com> writes:
Hello,

I tried using the curry function last night and I ran into a compilation 
issue.  Here's a simple example that demonstrates the issue:

import std.functional;
import std.stdio;

void strwrite(string input)
{
     writeln(input);
}

alias curry!(strwrite, "foo") writefoo;

void main()
{
     writefoo();
}

And the error message:

/apps/dmd2/linux/bin/../../src/phobos/std/functional.d(303): Error: 
tuple index 1 exceeds 1
/apps/dmd2/linux/bin/../../src/phobos/std/functional.d(9): Error: 
template instance std.functional.curry!(strwrite,"foo") error instantiating

The examples I found in the documentation used ints, IIRC, however I 
don't recall seeing anything that would prevent me from using a string 
in this case.  Am I doing something wrong or did I find an issue?

Casey
Jun 24 2010
parent sybrandy <sybrandy gmail.com> writes:
On 06/24/2010 06:54 PM, sybrandy wrote:
 Hello,

 I tried using the curry function last night and I ran into a compilation
 issue. Here's a simple example that demonstrates the issue:

 import std.functional;
 import std.stdio;

 void strwrite(string input)
 {
 writeln(input);
 }

 alias curry!(strwrite, "foo") writefoo;

 void main()
 {
 writefoo();
 }

 And the error message:

 /apps/dmd2/linux/bin/../../src/phobos/std/functional.d(303): Error:
 tuple index 1 exceeds 1
 /apps/dmd2/linux/bin/../../src/phobos/std/functional.d(9): Error:
 template instance std.functional.curry!(strwrite,"foo") error instantiating

 The examples I found in the documentation used ints, IIRC, however I
 don't recall seeing anything that would prevent me from using a string
 in this case. Am I doing something wrong or did I find an issue?

 Casey
Forgot to mention: this is occurring with the newest version of D2. (2.0.47)
Jun 24 2010