Templates array detection

2012-12-12 Thread Cube
Hi, I'm having a problem getting templates to work correctly. I want to handle arrays differently, but when I try to compile the following example code it says it matches more than 1 template. What is the correct way to do this? -- void main() { foo(1); foo([1,1]); } void foo(T)(T

Re: Templates array detection

2012-12-12 Thread bearophile
Cube: I'm having a problem getting templates to work correctly. I want to handle arrays differently, but when I try to compile the following example code it says it matches more than 1 template. What is the correct way to do this? -- void main() { foo(1); foo([1,1]); } void

Re: Parallelism Map and Reduce

2012-12-12 Thread Zardoz
On Tuesday, 11 December 2012 at 17:50:31 UTC, Ali Çehreli wrote: On 12/11/2012 08:12 AM, Zardoz wrote: Could you please move MapIntegrator() to module-level. Then it should work. Ali I try it and now even with normal Map function give me errors with dmd ! public Entity MapIntegrator (

Re: Templates array detection

2012-12-12 Thread Cube
On Wednesday, 12 December 2012 at 12:34:34 UTC, bearophile wrote: Cube: I'm having a problem getting templates to work correctly. I want to handle arrays differently, but when I try to compile the following example code it says it matches more than 1 template. What is the correct way to do

Re: Templates array detection

2012-12-12 Thread ixid
On Wednesday, 12 December 2012 at 12:34:34 UTC, bearophile wrote: Cube: I'm having a problem getting templates to work correctly. I want to handle arrays differently, but when I try to compile the following example code it says it matches more than 1 template. What is the correct way to do

Re: Templates array detection

2012-12-12 Thread bearophile
ixid: It's a pity it doesn't see T[] as the best fit and go with it on that basis. It's not a pity, it's a good design. Best fit makes languagecompiler complex, less predictable for the programmer, etc. Bye, bearophile

Static compiling with dmd

2012-12-12 Thread Zardoz
How I can compile with static linking with dmd ? I try with dmd -L-static but i get this error : /usr/bin/ld: cannot find -lgcc_s I used before gdc with -static options and owrked well on it, but I need to use now dmd.

Re: Templates array detection

2012-12-12 Thread Cube
Better example code for my other problem. How can I make the 3rd foo work on Datas? -- struct Data(T) { T elem; } void main() { foo(1); foo([1,1]); auto tmp1 = new Data!(int); tmp1.elem = 3; foo(tmp1); auto tmp2 = new Data!(string);

Re: Parallelism Map and Reduce

2012-12-12 Thread Ali Çehreli
On 12/12/2012 05:47 AM, Zardoz wrote: On Tuesday, 11 December 2012 at 17:50:31 UTC, Ali Çehreli wrote: On 12/11/2012 08:12 AM, Zardoz wrote: Could you please move MapIntegrator() to module-level. Then it should work. Ali I try it and now even with normal Map function give me errors with

Re: Templates array detection

2012-12-12 Thread Cube
On Wednesday, 12 December 2012 at 15:21:16 UTC, Ali Çehreli wrote: On 12/12/2012 06:49 AM, Cube wrote: Better example code for my other problem. How can I make the 3rd foo work on Datas? -- struct Data(T) { T elem; } Data is a struct template, not a type (until instantiated). void

Re: Templates array detection

2012-12-12 Thread bearophile
Ali Çehreli: This works: void foo(T)(T t) if(is(T == Data!T)) Try: void foo(T)(Data!T t) { Bye, bearophile

Re: Templates array detection

2012-12-12 Thread ixid
On Wednesday, 12 December 2012 at 14:21:22 UTC, bearophile wrote: ixid: It's a pity it doesn't see T[] as the best fit and go with it on that basis. It's not a pity, it's a good design. Best fit makes languagecompiler complex, less predictable for the programmer, etc. Bye, bearophile

Re: Templates array detection

2012-12-12 Thread Ali Çehreli
On 12/12/2012 07:37 AM, Cube wrote: On Wednesday, 12 December 2012 at 15:21:16 UTC, Ali Çehreli wrote: On 12/12/2012 06:49 AM, Cube wrote: Better example code for my other problem. How can I make the 3rd foo work on Datas? -- struct Data(T) { T elem; } Data is a struct

Re: Static compiling with dmd

2012-12-12 Thread Jonathan M Davis
On Wednesday, December 12, 2012 15:28:46 Zardoz wrote: How I can compile with static linking with dmd ? I try with dmd -L-static but i get this error : /usr/bin/ld: cannot find -lgcc_s I used before gdc with -static options and owrked well on it, but I need to use now dmd. At this

Re: Static compiling with dmd

2012-12-12 Thread Minas Mina
On Wednesday, 12 December 2012 at 14:28:48 UTC, Zardoz wrote: How I can compile with static linking with dmd ? I try with dmd -L-static but i get this error : /usr/bin/ld: cannot find -lgcc_s I used before gdc with -static options and owrked well on it, but I need to use now dmd. Try

Re: Templates array detection

2012-12-12 Thread bearophile
ixid: It seems very similar to a function overload to me. Why is picking T[] in preference to T different to picking uint over ulong for an overloaded function used on a uint? The name T can refer to any type, including a U[], while built-in types like uint are atomic, they can't refer to a

Re: static code generation p2

2012-12-12 Thread js.mdnq
On Thursday, 13 December 2012 at 01:09:28 UTC, js.mdnq wrote: Take the example here: http://forum.dlang.org/thread/vrupqijwqmccdpabm...@forum.dlang.org note how he provides the body of the method in the mixin. I would like to something similar to what he has done but provide the body of the

bringToFront() and arrays of char

2012-12-12 Thread Mu
Why doesn't the below code compile? How to rewrite it so that it does? Using: DMD64 D Compiler v2.060. Thank you. Code: import std.algorithm, std.ascii, std.stdio; void main() { char[] rot13 = lowercase.dup; bringToFront(rot13[0 .. 13], rot13[13 .. $]);

Re: bringToFront() and arrays of char

2012-12-12 Thread Ali Çehreli
On 12/12/2012 05:18 PM, Mu wrote: Why doesn't the below code compile? How to rewrite it so that it does? Using: DMD64 D Compiler v2.060. Thank you. Code: import std.algorithm, std.ascii, std.stdio; void main() { char[] rot13 = lowercase.dup; bringToFront(rot13[0 ..

Re: bringToFront() and arrays of char

2012-12-12 Thread Jonathan M Davis
On Wednesday, December 12, 2012 17:34:53 Ali Çehreli wrote: (There must be an easier way of doing that. :)) If you have a string that's really ASCII and you're _sure_ that it's only ASCII, then I'd suggest simply casting it to immutable(ubyte)[] and operating on that with all range based

Re: static code generation

2012-12-12 Thread js.mdnq
On Monday, 10 December 2012 at 22:01:37 UTC, Ali Çehreli wrote: On 12/10/2012 01:52 PM, js.mdnq wrote: I want to avoid having to wrap the code with as it disables highlighting and possibly other features(intellisense, etc...)) The q{} syntax is supposed to help with that issue. Emacs

Re: static code generation

2012-12-12 Thread dennis luehring
Am 13.12.2012 04:32, schrieb js.mdnq: I think the issue I have with all this is that when you put code inside a string you lose a lot of compile time features AFAICT. your right - but...try to come up with an similar (easy to implement) powerfull solution that is not based on strings and you