Re: Partially instantiating templates?

2011-02-01 Thread Magnus Lie Hetland
On 2011-01-31 19:46:53 +0100, Simen kjaeraas said: Magnus Lie Hetland mag...@hetland.org wrote: Hm. Using code quite similar to you, supplying a lambda in the second aliasing, I get this error: something.d(93): Error: template instance cannot use local '__dgliteral2(__T3)' as parameter to

Re: Partially instantiating templates?

2011-02-01 Thread Magnus Lie Hetland
On 2011-02-01 10:11:53 +0100, Magnus Lie Hetland said: On 2011-01-31 22:21:40 +0100, bearophile said: Magnus Lie Hetland: [snip] I'm accustomed to is the ability to assign to multiple variables, such as arg, val = minArg(...) (Yeah, I'm a Python guy... ;) I will eventually add a

Re: Partially instantiating templates?

2011-02-01 Thread bearophile
Magnus Lie Hetland: Saw your post on digitalmars.D now, about the currying of templates (i.e., the main topic here). I guess perhaps that was what you were talking about? Tuple unpacking syntax and template currying are two different things. Bye, bearophile

Re: Partially instantiating templates?

2011-02-01 Thread Magnus Lie Hetland
On 2011-02-01 10:49:23 +0100, bearophile said: Magnus Lie Hetland: Saw your post on digitalmars.D now, about the currying of templates (i.e., the main topic here). I guess perhaps that was what you were talking about? Tuple unpacking syntax and template currying are two different things.

Re: Partially instantiating templates?

2011-02-01 Thread Magnus Lie Hetland
On 2011-02-01 10:12:44 +0100, Magnus Lie Hetland said: On 2011-01-31 19:46:53 +0100, Simen kjaeraas said: Magnus Lie Hetland mag...@hetland.org wrote: Hm. Using code quite similar to you, supplying a lambda in the second aliasing, I get this error: something.d(93): Error: template

Re: Partially instantiating templates?

2011-02-01 Thread Simen kjaeraas
Magnus Lie Hetland mag...@hetland.org wrote: Hm. Just to make sure this *is* a bug, and I'm not just being a dumbass ... this is a tiny program that illustrates the problem (i.e., gives the error above). Perhaps the use of a local function here really is prohibited...? Maybe it is. It

Re: Partially instantiating templates?

2011-02-01 Thread bearophile
Magnus Lie Hetland: Yes, certainly. That was the point of this post -- that I misunderstood what you were talking about in the original post (where you said this topic right after my tuple unpacking paragraph) :) I will eventually add to bugzilla a request for tuple unpacking syntax, see

Re: Partially instantiating templates?

2011-02-01 Thread Simen kjaeraas
Magnus Lie Hetland mag...@hetland.org wrote: Sort of related (though perhaps only remotely) is the following, which won't compile (Error: static assert Bad unary function: f(a) for type int): Not related. unaryFun and binaryFun are simply glorified string mixins, and thus can only access

Re: Partially instantiating templates?

2011-02-01 Thread Magnus Lie Hetland
On 2011-02-01 16:00:16 +0100, Magnus Lie Hetland said: import std.functional, std.stdio; int f(int x) {return x;} void main() { alias unaryFun!(f(a)) g; writeln(g(3)); } Just to be clear -- I realize I could just have used unaryFun!f here (or just f, for that matter). The

Re: Partially instantiating templates?

2011-02-01 Thread Magnus Lie Hetland
On 2011-02-01 16:09:22 +0100, Simen kjaeraas said: Magnus Lie Hetland mag...@hetland.org wrote: Sort of related (though perhaps only remotely) is the following, which won't compile (Error: static assert Bad unary function: f(a) for type int): Not related. unaryFun and binaryFun are simply

Re: Partially instantiating templates?

2011-02-01 Thread Simen kjaeraas
Magnus Lie Hetland mag...@hetland.org wrote: On 2011-02-01 16:09:22 +0100, Simen kjaeraas said: Magnus Lie Hetland mag...@hetland.org wrote: Sort of related (though perhaps only remotely) is the following, which won't compile (Error: static assert Bad unary function: f(a) for type int):

Re: Partially instantiating templates?

2011-02-01 Thread Magnus Lie Hetland
On 2011-02-01 16:41:33 +0100, Simen kjaeraas said: That certainly makes sense. I just got thrown off by the example in std.algorithm: uint hashFun(string) { ... expensive computation ... } string[] array = ...; // Sort strings by hash, slow sort!(hashFun(a) hashFun(b))(array); The only way

Safer enum casts

2011-02-01 Thread bearophile
If I have an enum of chars, and I have a variable that contains a generic char, I may want to convert the second to an instance of the first one, safely (a normal cast is enough to do it unsafely). Is it a good idea to give this purpose to to!() (this idea is currently not implemented)?

Re: Safer enum casts

2011-02-01 Thread Jesse Phillips
bearophile Wrote: If I have an enum of chars, and I have a variable that contains a generic char, I may want to convert the second to an instance of the first one, safely (a normal cast is enough to do it unsafely). Is it a good idea to give this purpose to to!() (this idea is currently

Re: ASM access to array

2011-02-01 Thread Heinz
Wow, thanks for the reply. Changing the 'enum dsize' to 'uint dsize = 4;' seems to produce some results...i guess it's working now (i have no way to verify it is working but looks like bits are being rotated by rol). One thing, if i replace dsize with 4 in all lines, the code compiles but again

Re: Safer enum casts

2011-02-01 Thread bearophile
Jesse Phillips: I believe this is exactly what std.conv.to should do. It should be the safest and recommended way to do conversions. http://d.puremagic.com/issues/show_bug.cgi?id=5515 Bye, bearophile