Singleton, alias to self?
I'm not sure of how to use alias efficiently, so I want to know if I could somehow do this (psuedo-code) class Singleton { //So instead of calling `Singleton.getSingleton()` you just call `Singleton` alias this = getSingleon() //code for singleton... } Thanks in advance, vladde
Re: Is this a good singleton?
On Sunday, 14 February 2016 at 07:16:54 UTC, Russel Winder wrote: On Sat, 2016-02-13 at 18:58 +, Vladde Nordholm via Digitalmars-d- learn wrote: [...] Following the ACCU consensus: there is never, ever a good Singleton or reason to contemplate using one. Obviously though there are some good ones: about dialogues in GUIs for example. The good/evil-ness of Singleton is definitely in it's use: most people use Singleton wrongly, most uses should be banned. Hence the ACCU consensus. It's all about coupling and mostly testability of code.. Thanks. I'm using David Simcha's singleton now.
Is this a good singleton?
Hello. I have this singleton, -- class Singleton { private this() {} static __gshared typeof(this) instance = new this; } -- and I wonder if it has any weaknesses. Or is there a better way to make a Singleton? ,vladde,
Re: Compare types with `static if` in template function.
On Wednesday, 29 July 2015 at 22:40:08 UTC, Ali Çehreli wrote: You seem to be using type names instead of member names: static if(is(typeof(c) == dchar) || is(typeof(c) == char)) { slots[xy.y][xy.x].character = c; } else if(is(typeof(c) == fg)) { slots[xy.y][xy.x].fg = c; Should be ... color = c; } else if(is(typeof(c) == bg)) { slots[xy.y][xy.x].bg = c; ... background = c; } else if(is(typeof(c) == md)) { slots[xy.y][xy.x].md = c; ... mode = c; } Ali Thank you! This was a mistake on my end. Really glad you spotted it, saved me quite some headaches!