How to get the type of a derived class in a method of its base class?

2017-02-18 Thread Max Samukha via Digitalmars-d-learn
class A { this(T = this)() { static assert(is(T == B)); } } class B { } auto b = new B; Here, T becomes A, which may be reasonable but is completely useless. Is there a way to obtain the type of the class (or class instance reference) the method is called on?

Re: Converting multiple inheritance code into C ++ for D language

2017-02-18 Thread Jean Cesar via Digitalmars-d-learn
On Saturday, 18 February 2017 at 19:45:45 UTC, biozic wrote: On Saturday, 18 February 2017 at 19:05:14 UTC, Jean Cesar wrote: This is exactly what I want this code I did to understand how would apply multiple inheritance in D, C # also process using interfaces but the difference from C # to D

Re: Hello, folks! Newbie to D, have some questions!

2017-02-18 Thread Seb via Digitalmars-d-learn
On Saturday, 18 February 2017 at 21:09:20 UTC, ag0aep6g wrote: 5. Supposing I devote the time and energy and get up to speed on D, would the core language team be welcoming if I feel like I can contribute? Absolutely. Anyone is welcome to contribute. D is very much a volunteer effort. Also

Re: scope with if

2017-02-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 17 February 2017 at 20:06:19 UTC, berni wrote: I wonder if it's possible to do something like this: import std.stdio; void main(string[] args) { if (args[1]=="a") { write("A"); scope (exit) write("B"); } write("C"); } I expected the output to be ACB not

Re: Hello, folks! Newbie to D, have some questions!

2017-02-18 Thread berni via Digitalmars-d-learn
I'm new here too (never heard of D before 2017). c). The whole community seems infused with both the Feminism/SJW I didn't tried out Rust, but that would draw me away too. (Incidentally it was a comment on alternatives for Rust, that pointed me to D.) 2. I am also curious as to what would

Re: Hello, folks! Newbie to D, have some questions!

2017-02-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 18 February 2017 at 20:15:55 UTC, timmyjose wrote: My rudimentary knowledge of the D ecosystem tells me that there is a GC in D, but that can be turned off. Is this correct? Technically yes; you will lose core functionality, though, if you do. I don't have the complete list at

Re: Hello, folks! Newbie to D, have some questions!

2017-02-18 Thread ketmar via Digitalmars-d-learn
timmyjose wrote: Thanks for the very comprehensive response! I think most of my doubts are cleared now. You're right though that I'm probably worrying too much about GC with my current use case. i can tell you that i'm doing things like, for example, ZX Spectrum emulator and hobbyst

Re: Hello, folks! Newbie to D, have some questions!

2017-02-18 Thread Daniel Kozak via Digitalmars-d-learn
Dne 18.2.2017 v 21:15 timmyjose via Digitalmars-d-learn napsal(a): Hello folks, I am interested in learning D (just starting out, did a few of the exercises on the D tour), and had some questions before I decide to jump right in. My questions are genuinely motivated by my experiences and

Re: Hello, folks! Newbie to D, have some questions!

2017-02-18 Thread timmyjose via Digitalmars-d-learn
On Saturday, 18 February 2017 at 21:27:55 UTC, sarn wrote: On Saturday, 18 February 2017 at 20:15:55 UTC, timmyjose wrote: [...] Hi :) [...] Okay, yes, it's easy to turn off or control the GC. It's also easy to control memory allocation in general (unlike, say, Java, where it's

Re: Hello, folks! Newbie to D, have some questions!

2017-02-18 Thread sarn via Digitalmars-d-learn
On Saturday, 18 February 2017 at 21:09:20 UTC, ag0aep6g wrote: Also, some threads online mention that if we do turn off GC, some of the core std libraries may not fully work. Is this presumption also correct? Yes. Whenever a std function returns a new string or some such it's going to be

Re: Hello, folks! Newbie to D, have some questions!

2017-02-18 Thread sarn via Digitalmars-d-learn
On Saturday, 18 February 2017 at 20:15:55 UTC, timmyjose wrote: Hello folks, Hi :) 2. I am more interested in learning D as a pure systems programming language so that I can develop my own tools (not looking to develop an OS, just some grep-scale tools to start off with). In that regard, I

Re: Hello, folks! Newbie to D, have some questions!

2017-02-18 Thread timmyjose via Digitalmars-d-learn
Thanks for the very comprehensive response! I think most of my doubts are cleared now. You're right though that I'm probably worrying too much about GC with my current use case. Also thanks for the links - they should also come in very handy indeed. I managed to find some book recommendations

Re: Hello, folks! Newbie to D, have some questions!

2017-02-18 Thread ag0aep6g via Digitalmars-d-learn
On Saturday, 18 February 2017 at 20:15:55 UTC, timmyjose wrote: 2. I am more interested in learning D as a pure systems programming language so that I can develop my own tools (not looking to develop an OS, just some grep-scale tools to start off with). In that regard, I have a few concerns

Re: scope with if

2017-02-18 Thread berni via Digitalmars-d-learn
Just a note - I found something, that works: import std.stdio; void main(string[] args) { immutable cond = args[1]=="a"; if (cond) write("A"); scope (exit) if (cond) write("B"); write("C"); } I'm using the immutable variable to avoid, that the condition changes later.

Hello, folks! Newbie to D, have some questions!

2017-02-18 Thread timmyjose via Digitalmars-d-learn
Hello folks, I am interested in learning D (just starting out, did a few of the exercises on the D tour), and had some questions before I decide to jump right in. My questions are genuinely motivated by my experiences and expectations, so please forgive me if some questions don't come across

Re: Converting multiple inheritance code into C ++ for D language

2017-02-18 Thread biozic via Digitalmars-d-learn
On Saturday, 18 February 2017 at 19:05:14 UTC, Jean Cesar wrote: This is exactly what I want this code I did to understand how would apply multiple inheritance in D, C # also process using interfaces but the difference from C # to D is that C # already in the base class you have to define it

Re: Converting multiple inheritance code into C ++ for D language

2017-02-18 Thread Jean Cesar via Digitalmars-d-learn
On Saturday, 18 February 2017 at 16:27:51 UTC, biozic wrote: On Saturday, 18 February 2017 at 12:56:51 UTC, wiki wrote: On Saturday, 18 February 2017 at 09:33:25 UTC, biozic wrote: A mixin can be used to provide an base implementation for the methods of an interface, along with data members,

Re: Converting multiple inheritance code into C ++ for D language

2017-02-18 Thread biozic via Digitalmars-d-learn
On Saturday, 18 February 2017 at 12:56:51 UTC, wiki wrote: On Saturday, 18 February 2017 at 09:33:25 UTC, biozic wrote: A mixin can be used to provide an base implementation for the methods of an interface, along with data members, so that you don't have to define it in every class that

Re: multi-dimensional arrays, not arrays of arrays

2017-02-18 Thread XavierAP via Digitalmars-d-learn
Nice, thanks! Will check it out

Re: Converting multiple inheritance code into C ++ for D language

2017-02-18 Thread wiki via Digitalmars-d-learn
On Saturday, 18 February 2017 at 09:33:25 UTC, biozic wrote: On Friday, 17 February 2017 at 23:35:33 UTC, Jean Cesar wrote: On Friday, 17 February 2017 at 23:31:41 UTC, Adam D. Ruppe wrote: On Friday, 17 February 2017 at 23:11:25 UTC, Jean Cesar wrote: so I changed the code to use interface

Re: multi-dimensional arrays, not arrays of arrays

2017-02-18 Thread Ilya Yaroshenko via Digitalmars-d-learn
On Saturday, 18 February 2017 at 10:37:21 UTC, XavierAP wrote: Does D provide anything like this? Otherwise, was this ever considered and were reasons found not to have it? They are implemented as part of the Mir project. We call them ndslices. https://github.com/libmir/mir-algorithm Docs:

multi-dimensional arrays, not arrays of arrays

2017-02-18 Thread XavierAP via Digitalmars-d-learn
Does D provide anything like this? Otherwise, was this ever considered and were reasons found not to have it? I mean at least in C# (not talking about C/C++ at all) you can declare two kind of multi-dimensional arrays: T[][][] or T[,,]. The first is the same as the D ones, array of arrays

Re: Converting multiple inheritance code into C ++ for D language

2017-02-18 Thread biozic via Digitalmars-d-learn
On Friday, 17 February 2017 at 23:35:33 UTC, Jean Cesar wrote: On Friday, 17 February 2017 at 23:31:41 UTC, Adam D. Ruppe wrote: On Friday, 17 February 2017 at 23:11:25 UTC, Jean Cesar wrote: so I changed the code to use interface but how would I do so I could use the constructor in the same