Re: ElementType!(Range) problem

2011-04-06 Thread Ishan Thilina
--Philippe wrote:: ElementType acts on types. It takes a type and 'returns' (compiles to, actually) another type. You need to give it typeof(listR). Then, as ElementType!(typeof(listR)) is a type, you cannot pass it to writeln. Use .stringof to go from the type to a string representation of its

error Not the start of the UTF-8 sequence

2011-04-06 Thread spir
Hello, I get this error message: Not the start of the UTF-8 sequence without any other comment module name or whatnot. This happens when I just added toString to the following struct, and used it: struct Node { // Note: level is equal to the number of chars up to this node.

Re: error Not the start of the UTF-8 sequence

2011-04-06 Thread Kagamin
spir Wrote: Hello, I get this error message: Not the start of the UTF-8 sequence without any other comment module name or whatnot. This happens when I just added toString to the following struct, and used it: struct Node { // Note: level is equal to the number of

[SOLVED] [BUG?] Re: error Not the start of the UTF-8 sequence

2011-04-06 Thread spir
On 04/06/2011 11:53 AM, Kagamin wrote: spir Wrote: Hello, I get this error message: Not the start of the UTF-8 sequence without any other comment module name or whatnot. This happens when I just added toString to the following struct, and used it: struct Node { //

template alias parameters

2011-04-06 Thread enuhtac
Hi, I'm playing around with template alias parameters. At the moment I'm considering the following simple code: struct A {}; struct B( T ) { T t; }; struct C( alias T ) { T t; }; void main() { B!A a; C!A b; } What exactly is the difference between a and b? Both seem to do the

Re: incompatible types!

2011-04-06 Thread simendsjo
On 06.04.2011 02:15, Steven Schveighoffer wrote: On Tue, 05 Apr 2011 19:37:15 -0400, Caligo iteronve...@gmail.com wrote: It's just frustrating, that's all. Writing thousands of lines of code and having everything stop because of a compiler bug is just frustrating. I completely understand.

Why doesn't curry work with multiple arguments?

2011-04-06 Thread Andrej Mitrovic
import std.functional; void foo(int x, int y, int z) { } alias curry!(foo, 1, 2, 3) bar; Error: template instance curry!(foo,1,2,3) does not match template declaration curry(alias fun,alias arg) Shouldn't curry take a variable number of arguments and then check the length of the arguments

Re: Why doesn't curry work with multiple arguments?

2011-04-06 Thread Andrej Mitrovic
Andrej Mitrovic Wrote: Yes, I write a whole new function, but why do that when curry is there. Or so I thought.. Oops: *Yes, I _can_ write a whole new function

Re: Why doesn't curry work with multiple arguments?

2011-04-06 Thread Andrej Mitrovic
Here's a basic implementation: import std.stdio; import std.traits; import std.metastrings; template count(T...) { enum count = T.length; } template curry(alias fun, args...) { static if (args.length (ParameterTypeTuple!fun).length) { static assert(0, Format!(Tried to pass

Re: Why doesn't curry work with multiple arguments?

2011-04-06 Thread Andrej Mitrovic
Crap, that is a horrible implementation, I didn't take into account not binding all arguments. Be right back..

Re: Why doesn't curry work with multiple arguments?

2011-04-06 Thread Andrej Mitrovic
Ok, enjoy this monstrosity: template count(T...) { enum count = T.length; } template myCurry(alias fun, args...) { static if (args.length (ParameterTypeTuple!fun).length) { static assert(0, Format!(Tried to pass %s arguments, max is %s.,

Re: Why doesn't curry work with multiple arguments?

2011-04-06 Thread Andrej Mitrovic
It's still wrong, the tuple is backwards. Haha, that's what I get for not unittesting.

Re: Why doesn't curry work with multiple arguments?

2011-04-06 Thread bearophile
Andrej Mitrovic: Here's a basic implementation: I have some general comments: - Currying and partial function application are not exactly the same thing. So I am not sure the curry in std.functional is named correctly; - Partial application is important in a language that wants to support

Re: Why doesn't curry work with multiple arguments?

2011-04-06 Thread Andrej Mitrovic
Wow, talk about enlightement. I think I've done it now: import std.stdio; import std.traits; import std.metastrings; template count(T...) { enum count = T.length; } template myCurry(alias fun, args...) { static if (args.length (ParameterTypeTuple!fun).length) { static

Re: Why doesn't curry work with multiple arguments?

2011-04-06 Thread Andrej Mitrovic
On 4/6/11, bearophile bearophileh...@lycos.com wrote: - Currying and partial function application are not exactly the same thing. So I am not sure the curry in std.functional is named correctly; Maybe bind should be a better name. I'm not sure..

Re: Why doesn't curry work with multiple arguments?

2011-04-06 Thread bearophile
Andrej Mitrovic: Maybe bind should be a better name. I'm not sure.. In Python there is something similar that's named partial: http://docs.python.org/library/functools.html#functools.partial Bye, bearophile

Re: Why doesn't curry work with multiple arguments?

2011-04-06 Thread Andrej Mitrovic
Well this still hasn't solved my problem. Because I shouldn't bind from left to right, but arbitrarily. So ideally I would want this: void foo(string str, int x, int y, string str2) { } alias bind!(foo, null, 1, 2, null) twoStrings; twoStrings(abc, def); - foo(abc, 1, 2, def); I'm pretty

char[][] join == string

2011-04-06 Thread bearophile
Given an array of strings std.string.join() returns a single string: import std.string; void main() { string[] a1 = [hello, red]; string j1 = join(a1, ); // OK } But in a program I need an array of mutable arrays of chars. If I join the arrays I get a mutable array of chars. But I

Re: char[][] join == string

2011-04-06 Thread Ali Çehreli
On 04/06/2011 05:13 PM, bearophile wrote: Given an array of strings std.string.join() returns a single string: import std.string; void main() { string[] a1 = [hello, red]; string j1 = join(a1, ); // OK } But in a program I need an array of mutable arrays of chars. If I join

Re: template alias parameters

2011-04-06 Thread Jesse Phillips
enuhtac Wrote: Hi, I'm playing around with template alias parameters. At the moment I'm considering the following simple code: struct A {}; struct B( T ) { T t; }; struct C( alias T ) { T t; }; void main() { B!A a; C!A b; } What exactly is the