Re: Asserting that a base constructor is always called

2020-05-23 Thread Tim via Digitalmars-d-learn
On Sunday, 24 May 2020 at 00:51:17 UTC, Jonathan M Davis wrote: On Saturday, May 23, 2020 4:43:04 PM MDT Tim via Digitalmars-d-learn wrote: It is but I want to make sure for other cases in the future where I create a new class that inherits from GameObject. This was I can avoid future bugs by e

Re: Asserting that a base constructor is always called

2020-05-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 23, 2020 4:43:04 PM MDT Tim via Digitalmars-d-learn wrote: > It is but I want to make sure for other cases in the future where > I create a new class that inherits from GameObject. This was I > can avoid future bugs by ensure that all classes in the future > that inherit from GameO

Re: Asserting that a base constructor is always called

2020-05-23 Thread Tim via Digitalmars-d-learn
On Saturday, 23 May 2020 at 22:15:49 UTC, Ali Çehreli wrote: Is it not already called? I tried the following and it seems to work: import std.stdio; GameObject[1] world; enum layer = 0; /// Base class of most objects in the game class GameObject{ this(){ world[layer] = this; writeln

Re: Asserting that a base constructor is always called

2020-05-23 Thread Ali Çehreli via Digitalmars-d-learn
On 5/23/20 3:04 PM, Tim wrote: I have a base class GameObject: /// Base class of most objects in the game class GameObject{     this(){     world[layer] = this;     }     abstract void update(){}     void draw(){} } I want to make sure that whenever a class inherits from this, the ba

Asserting that a base constructor is always called

2020-05-23 Thread Tim via Digitalmars-d-learn
I have a base class GameObject: /// Base class of most objects in the game class GameObject{ this(){ world[layer] = this; } abstract void update(){} void draw(){} } I want to make sure that whenever a class inherits from this, the base constructor is always called. Eit

Re: Storing a reference to the calling object

2020-05-23 Thread Tim via Digitalmars-d-learn
On Saturday, 23 May 2020 at 09:48:57 UTC, Mike Parker wrote: Since you're using classes, one way is to use a common base class or an interface. But assuming "parent" is the owner of the Sprite instance, you might eliminate the dependency on the parent and have it update the Sprite's position wh

Re: Learning Vibe.d

2020-05-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 23 May 2020 at 15:47:59 UTC, Russel Winder wrote: Hi, I thought I would try and do the async version of my mock AVR850 using the vibe.d TCP stuff. This is not HTTP, it is proper networking! ;-) Problem one is that vibe.d sever processes never seem to terminate. I am using run

Make dub ignore dependencies when building docs?

2020-05-23 Thread NaN via Digitalmars-d-learn
Can you make dub ignore dependencies when building docs?

Re: How to flatten N-dimensional array?

2020-05-23 Thread Ali Çehreli via Digitalmars-d-learn
On 5/23/20 11:15 AM, Pavel Shkadzko wrote:> I have tried to implement a simple flatten function for multidimensional > I'd like to clarify a couple of questions first. > > How come Phobos doesn't have "flatten" function for arrays? We call in 'joiner'. I wrote something like this: import std.

Re: Learning Vibe.d

2020-05-23 Thread bauss via Digitalmars-d-learn
On Saturday, 23 May 2020 at 17:57:22 UTC, Russel Winder wrote: On Sat, 2020-05-23 at 16:56 +, bauss via Digitalmars-d-learn wrote: […] Had similar experiences on non-windows platforms. I forgot to mention I was on Linux (Debian Sid). I am (sort of) pleased it isn't just me – definitely u

How to flatten N-dimensional array?

2020-05-23 Thread Pavel Shkadzko via Digitalmars-d-learn
I have tried to implement a simple flatten function for multidimensional arrays with recursive templates but got stuck. Then I googled a little and stumped into complex https://rosettacode.org/wiki/Flatten_a_list#D implementation which requires your arrays to be either TreeList or Algebraic. T

Re: Learning Vibe.d

2020-05-23 Thread Russel Winder via Digitalmars-d-learn
On Sat, 2020-05-23 at 16:56 +, bauss via Digitalmars-d-learn wrote: […] > > Had similar experiences on non-windows platforms. I forgot to mention I was on Linux (Debian Sid). I am (sort of) pleased it isn't just me – definitely unhappy it has happened to others as well. > I think the soluti

Re: Learning Vibe.d

2020-05-23 Thread bauss via Digitalmars-d-learn
On Saturday, 23 May 2020 at 15:47:59 UTC, Russel Winder wrote: Hi, I thought I would try and do the async version of my mock AVR850 using the vibe.d TCP stuff. This is not HTTP, it is proper networking! ;-) Problem one is that vibe.d sever processes never seem to terminate. I am using run

Learning Vibe.d

2020-05-23 Thread Russel Winder via Digitalmars-d-learn
Hi, I thought I would try and do the async version of my mock AVR850 using the vibe.d TCP stuff. This is not HTTP, it is proper networking! ;-) Problem one is that vibe.d sever processes never seem to terminate. I am using runApplication or more likely runEventLoop in my main but it never return

Re: Spawn a Command Line application Window and output log information

2020-05-23 Thread BoQsc via Digitalmars-d-learn
On Tuesday, 19 May 2020 at 10:05:00 UTC, BoQsc wrote: On Monday, 18 May 2020 at 20:00:51 UTC, BoQsc wrote: I'm kind of stuck right now on how. Some more Updates and it seems that it is impossible to scroll the history of the output. Some relevant discussion: https://stackoverflow.com/a

std.container.array pointer

2020-05-23 Thread bauss via Digitalmars-d-learn
Is it possible to have a pointer to a nogc array? Like for regular arrays you can just do .ptr How would you do the same for a nogc array? The reason is I need to read different types of values from a nogc byte array. Ex. reading an int at offset 12 of the array. With normal arrays it can b

Re: Storing a reference to the calling object

2020-05-23 Thread Luis via Digitalmars-d-learn
On Saturday, 23 May 2020 at 09:27:46 UTC, Tim wrote: Hi all, I'm a little new to D and I'm wondering how I can store a reference to the calling object. I want to create a reference to an object's parent so that each time I go to update the sprite, it is able to grab its position from the parent

Re: Storing a reference to the calling object

2020-05-23 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 23 May 2020 at 09:27:46 UTC, Tim wrote: Hi all, I'm a little new to D and I'm wondering how I can store a reference to the calling object. I want to create a reference to an object's parent so that each time I go to update the sprite, it is able to grab its position from the parent

Re: Storing a reference to the calling object

2020-05-23 Thread drug via Digitalmars-d-learn
23.05.2020 12:27, Tim пишет: class Sprite{     /// Postional components of the sprite     int* x, y;     SDL_Surface* image_surface;     auto parent;     this(const char* path, auto parent){     writeln(*x);     this.parent = parent;     }     void update(){     // Copy lo

Storing a reference to the calling object

2020-05-23 Thread Tim via Digitalmars-d-learn
Hi all, I'm a little new to D and I'm wondering how I can store a reference to the calling object. I want to create a reference to an object's parent so that each time I go to update the sprite, it is able to grab its position from the parent. So if I have: class Sprite{ /// Postional com

Re: How to use base class & child class as parameter in one function ?

2020-05-23 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 22 May 2020 at 22:44:17 UTC, H. S. Teoh wrote: On Fri, May 22, 2020 at 09:39:16PM +, Vinod K Chandran via Digitalmars-d-learn wrote: [...] So in the same manner, i want void function(Base) = fnPtr wiil work with void function(Child) You cannot, because that's type unsafe:

Re: How to use base class & child class as parameter in one function ?

2020-05-23 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 22 May 2020 at 22:40:50 UTC, Steven Schveighoffer wrote: On 5/22/20 5:39 PM, Vinod K Chandran wrote: [...] That is the opposite of what you are thinking. A function pointer has to be valid based on its parameter types. Covariant functions are allowed. This is OK: void function(