Re: Singleton in Action?

2019-02-02 Thread Tony via Digitalmars-d-learn
On Saturday, 2 February 2019 at 16:56:45 UTC, Ron Tarrant wrote: So, my big question is, do I instantiate like this: DSingleton singleton = new DSingleton; Or like this: DSingleton singleton = singleton.get(); And subsequent calls would be...? The same? Using get() only? This seems to be a

Re: Singleton in Action?

2019-02-02 Thread Norm via Digitalmars-d-learn
On Saturday, 2 February 2019 at 16:56:45 UTC, Ron Tarrant wrote: Hi guys, I ran into another snag this morning while trying to implement a singleton. I found all kinds of examples of singleton definitions, but nothing about how to put them into practice. Can someone show me a code example fo

Re: Singleton in Action?

2019-02-02 Thread Norm via Digitalmars-d-learn
On Saturday, 2 February 2019 at 16:56:45 UTC, Ron Tarrant wrote: Hi guys, I ran into another snag this morning while trying to implement a singleton. I found all kinds of examples of singleton definitions, but nothing about how to put them into practice. [...] If you haven't already been t

Re: Singleton in Action?

2019-02-02 Thread angel via Digitalmars-d-learn
On Saturday, 2 February 2019 at 19:23:58 UTC, Ron Tarrant wrote: Thanks for the replies, fellow programmers. (generic, unisex, PC, and all-encompassing) If I could trouble someone for a complete working example so I have something to study, that would be excellent. I think that's what you r

Re: Singleton in Action?

2019-02-02 Thread Neia Neutuladh via Digitalmars-d-learn
On Sat, 02 Feb 2019 17:34:11 +, Eugene Wissner wrote: > For creation get() should be always used, since it is the most > convenient way to ensure that there is really only one instance of the > singleton. Just make this() private, so only you can create new > instances: > > private this() > {

Re: Singleton in Action?

2019-02-02 Thread Andre Pany via Digitalmars-d-learn
On Saturday, 2 February 2019 at 19:23:58 UTC, Ron Tarrant wrote: Thanks for the replies, fellow programmers. (generic, unisex, PC, and all-encompassing) If I could trouble someone for a complete working example so I have something to study, that would be excellent. I found here an example: h

Re: Singleton in Action?

2019-02-02 Thread Ron Tarrant via Digitalmars-d-learn
Thanks for the replies, fellow programmers. (generic, unisex, PC, and all-encompassing) If I could trouble someone for a complete working example so I have something to study, that would be excellent.

Re: Singleton in Action?

2019-02-02 Thread Eugene Wissner via Digitalmars-d-learn
On Saturday, 2 February 2019 at 16:56:45 UTC, Ron Tarrant wrote: Hi guys, I ran into another snag this morning while trying to implement a singleton. I found all kinds of examples of singleton definitions, but nothing about how to put them into practice. Can someone show me a code example fo

Re: Singleton in Action?

2019-02-02 Thread Russel Winder via Digitalmars-d-learn
On Sat, 2019-02-02 at 16:56 +, Ron Tarrant via Digitalmars-d-learn wrote: > Hi guys, and gals. > I ran into another snag this morning while trying to implement a > singleton. I found all kinds of examples of singleton > definitions, but nothing about how to put them into practice. General,

Singleton in Action?

2019-02-02 Thread Ron Tarrant via Digitalmars-d-learn
Hi guys, I ran into another snag this morning while trying to implement a singleton. I found all kinds of examples of singleton definitions, but nothing about how to put them into practice. Can someone show me a code example for how one would actually use a singleton pattern in D? When I did

Re: Return Value Optimization: specification, requirements?

2019-02-02 Thread Eugene Wissner via Digitalmars-d-learn
On Saturday, 2 February 2019 at 09:58:25 UTC, XavierAP wrote: I've heard here and there that D guarantees RVO, or is even specified to do so... Is it spelled out in the language specification or elsewhere? I haven't found it. The D spec is often not the right place to look for the specifica

Return Value Optimization: specification, requirements?

2019-02-02 Thread XavierAP via Digitalmars-d-learn
I've heard here and there that D guarantees RVO, or is even specified to do so... Is it spelled out in the language specification or elsewhere? I haven't found it. Do you know the exact requirements for RVO or NRVO to be possible in theory, and to be guaranteed in practice in D? Does it depe