(Maybe) Strange Behaviour of Field Initialization

2021-04-28 Thread eXodiquas via Digitalmars-d-learn
Hello everyone, I am playing around with DSFML and drawing some stuff on the screen. It works like a charm but I got some unexpected behavior when building a `Particle` class. My class looks like this: ```d class Particle : Drawable { CircleShape shape = new CircleShape(5); this(int x,

Re: (Maybe) Strange Behaviour of Field Initialization

2021-04-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 28 April 2021 at 15:09:36 UTC, eXodiquas wrote: ```d class Particle : Drawable { CircleShape shape = new CircleShape(5); This `new` is actually run at compile time, so every instance of Particle refers to the same instance of CircleShape (unless you rebind it). this.sha

Deriving a D-class from a CPP-class

2021-04-28 Thread Alain De Vos via Digitalmars-d-learn
Is it ok to do the following ? I.e. derive a D-class from a CPP-class. The compiler did not complained, and it was OK for him. ``` c++ -c MyClass.cpp ldc2 main.d MyClass.o -L-lstdc++ ``` ``` extern(C++){ class MyClass { public: int num=1;

Re: (Maybe) Strange Behaviour of Field Initialization

2021-04-28 Thread eXodiquas via Digitalmars-d-learn
On Wednesday, 28 April 2021 at 15:35:57 UTC, Adam D. Ruppe wrote: On Wednesday, 28 April 2021 at 15:09:36 UTC, eXodiquas wrote: ```d class Particle : Drawable { CircleShape shape = new CircleShape(5); This `new` is actually run at compile time, so every instance of Particle refers to the sa

Re: Deriving a D-class from a CPP-class

2021-04-28 Thread Alain De Vos via Digitalmars-d-learn
PS: I managed to link to phobo's/runtime & wxgtk at the same time. It goes like this [So someone does not need to re-invent the weel] ``` ldc2 - c test.d c++ test.o -o test -L/usr/local/lib -lphobos2-ldc -ldruntime-ldc -Wl,--gc-sections -lexecinfo -lpthread -lm -m64 `wxgtk3u-3.0-config --cxxfla

Re: Deriving a D-class from a CPP-class

2021-04-28 Thread Alain De Vos via Digitalmars-d-learn
Following code produces a linker error. d: error: undefined symbol: wxApp::OnInit() ``` extern(C++) {class wxApp { public: bool OnInit(); //virtual bool Oninit(); } } class MYAPP: wxApp {

Re: Deriving a D-class from a CPP-class

2021-04-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 28 April 2021 at 19:46:00 UTC, Alain De Vos wrote: Following code produces a linker error. d: error: undefined symbol: wxApp::OnInit() ``` extern(C++) {class wxApp { public: bool OnInit(); //virtual bool

Re: vibe-core sporadic internal errors

2021-04-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/27/21 11:48 AM, Steven Schveighoffer wrote: I suspect vibe-core or event core may have some subtle bugs in them that are not easily repeatable, but often result in half-rendered web pages. Has anyone else seen this? I recently updated to the latest vibe-core and vibe to see if the problem

dlang vs crystal-language

2021-04-28 Thread Alain De Vos via Digitalmars-d-learn
What are the strengths and weaknesses comparing the two languages ? I can name a strength of dlang is the working binding to tk and gtk.

Re: serve-d and emacs

2021-04-28 Thread Christian Köstlin via Digitalmars-d-learn
On 26.04.21 21:13, WebFreak001 wrote: On Monday, 26 April 2021 at 18:45:08 UTC, Christian Köstlin wrote: Does anybody use serve-d with emacs (lsp-mode or eglot)? I would love to see the configuration! Kind regards, Christian if you configure it yourself, feel free to share the configuration a

Re: dlang vs crystal-language

2021-04-28 Thread Imperatorn via Digitalmars-d-learn
On Wednesday, 28 April 2021 at 22:41:03 UTC, Alain De Vos wrote: What are the strengths and weaknesses comparing the two languages ? I can name a strength of dlang is the working binding to tk and gtk. Crystal has no installer for Windows

Re: What's a good approach to DRY with the block code of a case-statement?

2021-04-28 Thread z via Digitalmars-d-learn
I'd recommend you to use templates with alias parameters but you mentioned that you need to retain function context(for gotos, continue, break, etc...) One thing you could do is mix the ugly mixin solution with the good one: ```D //inside the function, so that you can access locals pragma(inlin

Re: dlang vs crystal-language

2021-04-28 Thread Berni44 via Digitalmars-d-learn
On Thursday, 29 April 2021 at 05:41:45 UTC, Imperatorn wrote: Crystal has no installer for Windows Is this a strength or a weakness? (SCNR)

Re: dlang vs crystal-language

2021-04-28 Thread Siemargl via Digitalmars-d-learn
On Wednesday, 28 April 2021 at 22:41:03 UTC, Alain De Vos wrote: What are the strengths and weaknesses comparing the two languages ? I can name a strength of dlang is the working binding to tk and gtk. Crystal is Web-only focused. And Crystal is not popular, even compared to D.

Re: Deriving a D-class from a CPP-class

2021-04-28 Thread evilrat via Digitalmars-d-learn
On Wednesday, 28 April 2021 at 19:46:00 UTC, Alain De Vos wrote: It is rather clear what I want to achieve but virtual functions give me headache because dlang does not now the word virtual. It's virtual by default. The opposite is `final`.