Re: can't zip a char[5], string[5], real[5]

2015-10-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, October 21, 2015 14:11:20 anonymous via Digitalmars-d-learn wrote: > On Wednesday, 21 October 2015 at 14:06:54 UTC, Shriramana Sharma > wrote: > > import std.stdio, std.range; > > void mywrite(char [5] chars, real[5] vals) > > { > > static string [5] fmts = ["%9.4f, ", "%9.4f; ",

Re: can't zip a char[5], string[5], real[5]

2015-10-21 Thread anonymous via Digitalmars-d-learn
On Wednesday, 21 October 2015 at 14:06:54 UTC, Shriramana Sharma wrote: import std.stdio, std.range; void mywrite(char [5] chars, real[5] vals) { static string [5] fmts = ["%9.4f, ", "%9.4f; ", "%3d, ", "%3d, ", "%3d\n"]; foreach (e; zip(chars, fmts, vals)) write(e[0], " = ",

Re: toString"z"?

2015-10-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 21 October 2015 at 14:27:52 UTC, Shriramana Sharma wrote: std.string.toStringz – why the strange name with z instead of toString0 or toCString? `stringz` is a traditional name for a Zero terminated string.

toString"z"?

2015-10-21 Thread Shriramana Sharma via Digitalmars-d-learn
std.string.toStringz – why the strange name with z instead of toString0 or toCString? -- Shriramana Sharma, Penguin #395953

Re: What's wrong in this templatized operator overload ?

2015-10-21 Thread MobPassenger via Digitalmars-d-learn
On Thursday, 22 October 2015 at 04:01:16 UTC, Mike Parker wrote: On Thursday, 22 October 2015 at 03:19:49 UTC, MobPassenger wrote: code: --- struct Foo { bool opIn_r(T)(T t){return false;} } This needs to be marked with const: struct Foo { bool opIn_r(T)(T t) const {return false;} }

Re: What's wrong in this templatized operator overload ?

2015-10-21 Thread Cauterite via Digitalmars-d-learn
On Thursday, 22 October 2015 at 04:25:01 UTC, MobPassenger wrote: On Thursday, 22 October 2015 at 04:01:16 UTC, Mike Parker wrote: On Thursday, 22 October 2015 at 03:19:49 UTC, MobPassenger wrote: code: --- struct Foo { bool opIn_r(T)(T t){return false;} } This needs to be marked with

Re: What's wrong in this templatized operator overload ?

2015-10-21 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 22 October 2015 at 03:19:49 UTC, MobPassenger wrote: code: --- struct Foo { bool opIn_r(T)(T t){return false;} } This needs to be marked with const: struct Foo { bool opIn_r(T)(T t) const {return false;} }

Re: What's wrong in this templatized operator overload ?

2015-10-21 Thread Vladimir Panteleev via Digitalmars-d-learn
On Thursday, 22 October 2015 at 03:21:35 UTC, MobPassenger wrote: On Thursday, 22 October 2015 at 03:18:25 UTC, MobPassenger wrote: code: Plz don't reply, there's been a forum bug while posting. What forum bug would that be?

Re: Implicit conversion rules

2015-10-21 Thread Maxim Fomin via Digitalmars-d-learn
On Wednesday, 21 October 2015 at 19:49:35 UTC, Ali Çehreli wrote: On 10/21/2015 12:37 PM, Sigg wrote: > cause at least few more "fun" side effects. One of those side effects would be function calls binding silently to another overload: void foo(bool){/* ... */} void foo(int) {/* ... */}

can't zip a char[5], string[5], real[5]

2015-10-21 Thread Shriramana Sharma via Digitalmars-d-learn
import std.stdio, std.range; void mywrite(char [5] chars, real[5] vals) { static string [5] fmts = ["%9.4f, ", "%9.4f; ", "%3d, ", "%3d, ", "%3d\n"]; foreach (e; zip(chars, fmts, vals)) write(e[0], " = ", e[1].format(e[2])); } Compiling gives: zip_string.d(5): Error: template

How to install DMD 64bit on Windows?

2015-10-21 Thread Gary Willoughby via Digitalmars-d-learn
How to install DMD 64bit on Windows? Is it just a case of downloading from here and it just works? http://dlang.org/download.html Or do I need Visual Studio installed?

Implicit conversion rules

2015-10-21 Thread Sigg via Digitalmars-d-learn
I started reading "The D programming Language" earlier, and came to the "2.3.3 Typing of Numeric Operators" section which claims that "if at least one participant has type ulong, the other is implicitly converted to ulong prior to the application and the result has type ulong.". Now I

Re: How to install DMD 64bit on Windows?

2015-10-21 Thread Adam D. Ruppe via Digitalmars-d-learn
Use the .exe installer and it will offer to download and install visual studio for you as part for its process.

Re: Overloading an imported function

2015-10-21 Thread Shriramana Sharma via Digitalmars-d-learn
anonymous wrote: > Huh. I can't find any specification on this, but apparently the local > overload set shadows any imported overload sets completely. Should I file a bug on this then? -- Shriramana Sharma, Penguin #395953

Re: Overloading an imported function

2015-10-21 Thread anonymous via Digitalmars-d-learn
On Wednesday, October 21, 2015 08:28 PM, Shriramana Sharma wrote: > Kagamin wrote: > >> http://dlang.org/hijack.html > > Thanks people, but even as per the rules: > > 1. Perform overload resolution independently on each overload set > 2. If there is no match in any overload set, then error >

Re: Implicit conversion rules

2015-10-21 Thread Ali Çehreli via Digitalmars-d-learn
On 10/21/2015 12:37 PM, Sigg wrote: > cause at least few more "fun" side effects. One of those side effects would be function calls binding silently to another overload: void foo(bool){/* ... */} void foo(int) {/* ... */} auto a = 0; // If the type were deduced by the value, foo(a);

Re: How to install DMD 64bit on Windows?

2015-10-21 Thread Brad Anderson via Digitalmars-d-learn
On Wednesday, 21 October 2015 at 18:50:08 UTC, Adam D. Ruppe wrote: Use the .exe installer and it will offer to download and install visual studio for you as part for its process. I don't know if that feature has made it into a release yet. I don't think Vc2015 is supported yet either in a

Re: Implicit conversion rules

2015-10-21 Thread anonymous via Digitalmars-d-learn
On Wednesday, October 21, 2015 07:53 PM, Sigg wrote: > void func() { > int a = -10; > ulong b = 0; > ulong c = a + b; > writefln("%s", c); > } > > out: 18446744073709551574 > > But shouldn't declaring c as auto force compiler to go extra step >

Re: Implicit conversion rules

2015-10-21 Thread Sigg via Digitalmars-d-learn
On Wednesday, 21 October 2015 at 19:07:24 UTC, anonymous wrote: The problem is of course that int and ulong have no common super type, at least not in the primitive integer types. int supports negative values, ulong supports values greater than long.max. Yes, I'm well aware of that. I was

Re: Implicit conversion rules

2015-10-21 Thread Marco Leise via Digitalmars-d-learn
Am Wed, 21 Oct 2015 12:49:35 -0700 schrieb Ali Çehreli : > On 10/21/2015 12:37 PM, Sigg wrote: > > > cause at least few more "fun" side effects. > > One of those side effects would be function calls binding silently to > another overload: > > void foo(bool){/* ... */} >

Re: std.uni general character category

2015-10-21 Thread Charles Hixson via Digitalmars-d-learn
On 10/20/2015 10:38 AM, Charles Hixson via Digitalmars-d-learn wrote: In std.uni (D Lib 2.068.2) I can no longer see how to get the general category code for a character. Does anyone know what the currently supported way to do that is? I thought I remembered that I used to be able to

Re: Overloading an imported function

2015-10-21 Thread Shriramana Sharma via Digitalmars-d-learn
Kagamin wrote: > http://dlang.org/hijack.html Thanks people, but even as per the rules: 1. Perform overload resolution independently on each overload set 2. If there is no match in any overload set, then error 3. If there is a match in exactly one overload set, then go with that 4. If there is

Re: Implicit conversion rules

2015-10-21 Thread Maxim Fomin via Digitalmars-d-learn
On Wednesday, 21 October 2015 at 22:49:16 UTC, Marco Leise wrote: Am Wed, 21 Oct 2015 12:49:35 -0700 schrieb Ali Çehreli : On 10/21/2015 12:37 PM, Sigg wrote: > cause at least few more "fun" side effects. One of those side effects would be function calls binding

error detected at """ ch in unicode.C """ Library error?

2015-10-21 Thread Charles Hixson via Digitalmars-d-learn
To me this looks like a library error, but I'm not sure. Any suggestions importstd.uni; chargcCat1(dchar ch) { if(ch in unicode.L)return'L';//Letter if(ch in unicode.M)return'M';//Mask if(ch in unicode.C)

What's wrong in this templatized operator overload ?

2015-10-21 Thread MobPassenger via Digitalmars-d-learn
code: --- struct Foo { bool opIn_r(T)(T t){return false;} } static immutable Foo foo; // ouch //static Foo foo; // OK void main() { assert("a" !in foo); } --- output: --- Error: template Foo.opIn_r cannot deduce function from argument types !()(string) immutable, candidates are:

What's wrong in this templatized operator overload ?

2015-10-21 Thread MobPassenger via Digitalmars-d-learn
code: --- struct Foo { bool opIn_r(T)(T t){return false;} } static immutable Foo foo; // ouch //static Foo foo; // OK void main() { assert("a" !in foo); }

Re: What's wrong in this templatized operator overload ?

2015-10-21 Thread MobPassenger via Digitalmars-d-learn
On Thursday, 22 October 2015 at 03:18:25 UTC, MobPassenger wrote: code: Plz don't reply, there's been a forum bug while posting. Full post is here: http://forum.dlang.org/thread/kaqyeiakjunqoexos...@forum.dlang.org

Re: Overloading an imported function

2015-10-21 Thread Kagamin via Digitalmars-d-learn
http://dlang.org/hijack.html

Re: Overloading an imported function

2015-10-21 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 21 October 2015 at 12:05:27 UTC, Shriramana Sharma wrote: import std.math; real round(real val, int prec) { real pow = 10 ^^ prec; return round(val * pow) / pow; } Trying to compile this I get: foo.d(5): Error: function foo.round (real val, int prec) is not callable

Re: kxml - parsing AWS API xml respond

2015-10-21 Thread opticron via Digitalmars-d-learn
On Tuesday, 20 October 2015 at 16:53:19 UTC, holo wrote: When im checking instance name with such code: auto test = list.parseXPath(`//tagSet/item[key="Name"]/value`)[0].goCData; it is compiling properly but it is breaking program when is no name set. I make quick workaround:

Overloading an imported function

2015-10-21 Thread Shriramana Sharma via Digitalmars-d-learn
import std.math; real round(real val, int prec) { real pow = 10 ^^ prec; return round(val * pow) / pow; } Trying to compile this I get: foo.d(5): Error: function foo.round (real val, int prec) is not callable using argument types (real) When I've imported std.math which contains

Re: Just one time

2015-10-21 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 20 October 2015 at 18:08:33 UTC, Ali Çehreli wrote: On 10/20/2015 08:48 AM, Andrea Fontana wrote: It happens I need to perform an operation just one time (inside a function, a loop...) An idea that uses a function pointer where the first step does its task and then sets the