Jesus4Lyf
Good Idea™
- Reaction score
- 397
JASS:
library_once GlobalGroup
globals
group GROUP=CreateGroup()
endglobals
endlibrary
library MyLib requires GlobalGroup
...
I don't think it is appropriate to redirect someone to get GroupUtils or something for the sake of this (the global group), BUT...
We could standardise this for use. It is as simple as putting the top 5 lines at the end (or start) of your library, and will not collide with other systems which do the same - if you have two libraries with this line at the top, it will implement once and share the group.
I think it would be very neat. The best advantage is not saving one handle - it is if you use a group in a system only to do enums on map initialisation and then would destroy it, as this leaks.
But then I think this is madness because:
JASS:
library_once GlobalGroup uses optional GroupUtils
globals
group GROUP
endglobals
private struct Init extends array
private static method onInit takes nothing returns nothing
static if LIBRARY_GroupUtils then
set GROUP=ENUM_GROUP
else
set GROUP=CreateGroup()
endif
endmethod
endstruct
endlibrary
And so it grows. o.o
(Actually, I kinda like it.)