StdLib

by Ter13
Essential standardized features for use in any DM project.
ID:2287769
 
Resolved
Not everybody is gonna be as in love with this pattern as we are, but it's damn useful in the absence of static types.
Applies to:StdLib 1.2
Status: Resolved (2.2)

This issue has been resolved.
All over all of my projects, I'm finding myself writing this pattern:

var
list/singletons

singleton
var
id
sometype
id = "herpyderp"
othertype
id = "derpyherp"

INIT_EVENT(init_singletons)
var/list/l = list(), id, singleton/s
for(var/v in typesof(/singleton))
s = v
if((id = initial(s.id)))
l[id] = new v()
global.singletons = l


It would be nice to standardize this behavior into StdLib so that this can be reduced to a single invocation:

var
list/singletons

singleton
id
sometype
id = "herpyderp"
othertype
id = "derpyherp"

INIT_EVENT(init_singletons)
singletons = singleton_init(/singleton)
Ter13 resolved issue with message:
Not everybody is gonna be as in love with this pattern as we are, but it's damn useful in the absence of static types.