Singleton Object, calling member functions using UFCS (an "ugly?" example) ... better way?

james.p.leblanc james.p.leblanc at gmail.com
Thu Sep 2 04:33:46 UTC 2021


On Wednesday, 1 September 2021 at 22:11:29 UTC, user1234 wrote:
> On Wednesday, 1 September 2021 at 22:01:12 UTC, user1234 wrote:

```
>> ProcessPipes gnuplot () {
>>     __gshared ProcessPipes pipe;
>>     return pipe.pid ? pipe : (pipe = 
>> pipeProcess("/usr/local/bin/gnuplot"));
>> }
```

user1234,

Thanks!  This is perfect, getting rid of the class altogether.

Yes, as pointed out in your response, that class was rather 
useless.
(For some unknown reason, I had been stuck on creating a 
singleton to
avoid multiple gnuplot processes -- very unnecessary as I now 
see.).

The ternary operator with the pipe id is much cleaner and leaner.

Thanks again, for your time, energy and insight.

Best Regards,
James



More information about the Digitalmars-d-learn mailing list