On Friday, 14 August 2015 at 09:21:56 UTC, DarthCthulhu wrote:
I only want to access the logger object when the program is compiled with the -debug option, so I don't want to pass it along to the object constructor or set a member as a reference to it (which is both tedious and pointless if not in -debug mode). The simple solution is to make the Logger class a singleton (can D do singletons? I presume it's possible, but I haven't really looked into it), but is there a means in D that is considered a better way to do this?
D can do singletons, the regular java/c# way, or you can just have an object on a module level.
You can also debug{} the field.