Re: Put Tuple in templates in a class fails
On Sun, May 13, 2012 at 11:58 AM, Xan wrote: > Thank you very much, Philippe. > > I have several questions: > > * Why do you think I can't compose functions with tuples? Your implentation > does exactly this, isn't? Well, in D functions can only return one value. So you cannot compose them with functions asking for more than one argument. For example, your code allows Algorisme!(int, double, string, float[]), which needs a 3-tuple as input (namely, (double,string,float[]) ) and returns an int. What kind of other Algorisme could be used as input for the one before? In general, you'll compose only functions taking one type and returning one type. Except if you auto-detect a std.typecons.Tuple and crack it open, I guess. > > * What is RHS? Right Hand Side (as opposed to lhs, Left Hand Side), the thing on the right-hand side of the operator. Sorry for the acronym. Philippe
Re: Put Tuple in templates in a class fails
Thank you very much, Philippe. I have several questions: * Why do you think I can't compose functions with tuples? Your implentation does exactly this, isn't? * What is RHS? Thanks, Xan. On Thursday, 10 May 2012 at 20:17:12 UTC, Philippe Sigaud wrote: On Thu, May 10, 2012 at 4:48 PM, Xan wrote: public class Algorisme(V,U...) { but when I do: https://gist.github.com/2653643 I get error: prova_amb_tuples_a_Algorisme.d:84: Error: 'alg' is not of arithmetic type, it is a prova_amb_tuples_a_Algorisme.Algorisme!(int,int).Algorisme prova_amb_tuples_a_Algorisme.d:84: Error: 'alg2' is not of arithmetic type, it is a prova_amb_tuples_a_Algorisme.Algorisme!(int,int).Algorisme You have to help the type-deduction algorithm a bit. By exposing the Domini/Codomini tuples, for example. Here: https://gist.github.com/2655583 See the new template constraint on lines 52-54 and the helper template at the beginning of the file. Also, in the string example, you inverted the domain and codomain. Btw, I'm not sure you can compose function with tuple-domains/codomains in general... Philippe
Re: Put Tuple in templates in a class fails
On Thu, May 10, 2012 at 4:48 PM, Xan wrote: > public class Algorisme(V,U...) { > > but when I do: https://gist.github.com/2653643 > > I get error: > prova_amb_tuples_a_Algorisme.d:84: Error: 'alg' is not of arithmetic type, > it is a prova_amb_tuples_a_Algorisme.Algorisme!(int,int).Algorisme > prova_amb_tuples_a_Algorisme.d:84: Error: 'alg2' is not of arithmetic type, > it is a prova_amb_tuples_a_Algorisme.Algorisme!(int,int).Algorisme You have to help the type-deduction algorithm a bit. By exposing the Domini/Codomini tuples, for example. Here: https://gist.github.com/2655583 See the new template constraint on lines 52-54 and the helper template at the beginning of the file. Also, in the string example, you inverted the domain and codomain. Btw, I'm not sure you can compose function with tuple-domains/codomains in general... Philippe
Put Tuple in templates in a class fails
Hi, I have this code: https://gist.github.com/2653620 and I want to change public class Algorisme(U,V) { to public class Algorisme(V,U...) { but when I do: https://gist.github.com/2653643 I get error: prova_amb_tuples_a_Algorisme.d:84: Error: 'alg' is not of arithmetic type, it is a prova_amb_tuples_a_Algorisme.Algorisme!(int,int).Algorisme prova_amb_tuples_a_Algorisme.d:84: Error: 'alg2' is not of arithmetic type, it is a prova_amb_tuples_a_Algorisme.Algorisme!(int,int).Algorisme What fails? Thanks in advance, Xan.