Is it possible to request a code review?
rikki cattermole
rikki at cattermole.co.nz
Thu Dec 14 04:12:33 UTC 2017
On 14/12/2017 3:57 AM, IM wrote:
snip
> - Is this the idiomatic way to define a singleton in D?:
> https://gitlab.com/3d_immortal/libdtasks/blob/master/src/tasks/TaskSystem.d#L24.
You say singleton I think wrong.
Use free-functions and globals instead.
Singletons are always a code smell that OOP based languages like to say
are a 'good thing'.
e.g.
module taskmgr;
import task;
private __gshared {
Task[] tasks;
}
Task[] getTasks() {
return tasks;
}
void clearTasks() {
tasks = null;
}
void addTask(Task t) {
tasks ~= t;
}
More information about the Digitalmars-d
mailing list