Re: Downloading Files in D

2014-09-11 Thread Danyal Zia via Digitalmars-d-learn
On Thursday, 11 September 2014 at 17:37:24 UTC, Nordlöw wrote: Ok, thanks. And I guess vibe.d can do this aswell without external dependencies, right? I'm also interested to know how this can be done with vibe.d...

Re: UFCS doesn't work in some cases

2014-09-10 Thread Danyal Zia via Digitalmars-d-learn
On Tuesday, 9 September 2014 at 18:46:31 UTC, ketmar via Digitalmars-d-learn wrote: UFCS is not working for nested functions. this is not a bug, it was designed this way. the same for 'with', i believe. Apparently it is a bug that UFCS doesn't work with 'with' statement.

UFCS doesn't work in some cases

2014-09-09 Thread Danyal Zia via Digitalmars-d-learn
Hi, I don't know if this has been mentioned before, but I found two strange cases where UFCS doesn't work. Case # 1: When the functions for UFCS are defined inside main scope class Rect { int x = 20; int y = 20; } void main() { import std.stdio : writeln; int

Re: Installing LDC on Windows

2014-09-06 Thread Danyal Zia via Digitalmars-d-learn
On Saturday, 6 September 2014 at 11:13:20 UTC, Russel Winder via Digitalmars-d-learn wrote: OK I installed LDC pre-built on MinGW for Windows on Windows and then Installed MinGW for Windows but when I run ldc2 it tells me libgcc_s_dw2-1.dll is missing. Is this problem soluble by any means

Re: Really nooB question - @property

2014-07-21 Thread Danyal Zia via Digitalmars-d-learn
On Sunday, 20 July 2014 at 16:35:52 UTC, Eric wrote: There are a lot of discussions in the forums about how @property should or could be implemented. But I can't seem to find anything that explains why or when I should use @property with the current compiler. Can anyone explain why and when

Re: DStyle: Braces on same line

2014-07-14 Thread Danyal Zia via Digitalmars-d-learn
On Sunday, 13 July 2014 at 16:10:31 UTC, Gary Willoughby wrote: Here is the 'official' style that is followed by most people including me. http://dlang.org/dstyle.html Unrelated to my original question. I already read that before asking.

Re: DStyle: Braces on same line

2014-07-13 Thread Danyal Zia via Digitalmars-d-learn
On Sunday, 13 July 2014 at 10:18:23 UTC, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: However, I do think there's value in deliberately matching the code style of the standard library, as it extends the volume of public D code with a common style. So unless you have a strong personal

DStyle: Braces on same line

2014-07-12 Thread Danyal Zia via Digitalmars-d-learn
Hi, I noticed that in Andrei's talks and his book, he used braces on the same line of delcaration, however Phobos and other D libraries I know use braces on their own line. Now I'm in a position where I need to take decision on coding style of my library and I get accustomed to use braces on

Re: struct template help

2014-07-12 Thread Danyal Zia via Digitalmars-d-learn
On Saturday, 12 July 2014 at 19:19:28 UTC, seany wrote: For reasons further down in the software, I need to do this with a pointer. How do I do it with a pointer, please? I don't know what are you trying to achieve, but if that's what you want, you can do: void MYfunction() { auto

Re: struct template help

2014-07-12 Thread Danyal Zia via Digitalmars-d-learn
On Saturday, 12 July 2014 at 19:32:48 UTC, seany wrote: do I have to initialize all variables of the struct? or may I also use a this(){} in the struct and initialize only those which are known at a given moment? You can initialize in constructor this(), but you can't initialize partial

Re: struct template help

2014-07-12 Thread Danyal Zia via Digitalmars-d-learn
On Saturday, 12 July 2014 at 19:42:13 UTC, Ali Çehreli wrote: Actually, that works too but members must be initialized from the beginning. The trailing ones are left with .init values: struct S { int i; string s; } void main() { auto s = new S(42); static assert(is (typeof(s)

Re: DStyle: Braces on same line

2014-07-12 Thread Danyal Zia via Digitalmars-d-learn
On Saturday, 12 July 2014 at 19:35:11 UTC, anonymous wrote: There is another stylistic choice which I do find confusing: capitalized identifiers for non-types, e.g. variables and functions. Please don't do that. Agreed about variables and functions. However I personally prefer to use

Using two flags in conditonal compilation (version)

2014-06-25 Thread Danyal Zia via Digitalmars-d-learn
Hi, In the development of my library, I'm in a position where I need to add support for multiple compilers. For instance, supporting both the assembly of LDC/DMD and GDC. I want to do something like: version(DigitalMars LDC) { } However, it doesn't compile which forces me to rewrote the

Converting from C const(dchar*) to dstring

2014-06-24 Thread Danyal Zia via Digitalmars-d-learn
Hi, I like to print the strings from a C function that returns const(dchar*), but I can't make the conversion to dstring. I can convert vice versa by: dstring text = Hello; const(dchar)* str = toUTFz!(const(dchar)*)(text); // passing it to C function prints Hello However, I don't have the

Re: Converting from C const(dchar*) to dstring

2014-06-24 Thread Danyal Zia via Digitalmars-d-learn
On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer wrote: const(dchar *)x = ...; // assuming 0 terminated dstring text = x[0..x.strlen].idup; -Steve const(dchar)* x = Hello\0; dstring text = x[0..x.strlen].idup; writeln(text); Error: no property 'strlen' for type 'const(dchar)*'

Re: Converting from C const(dchar*) to dstring

2014-06-24 Thread Danyal Zia via Digitalmars-d-learn
On Tuesday, 24 June 2014 at 18:34:31 UTC, Chris Cain wrote: You can do what he said, but you'll have to write your own strlen function: something like: size_t strlen(in dchar* s) pure @system nothrow { size_t pos = 0; dchar term = '\0'; while(s[pos] != term)