ID:259255
 
It would be useful if a class could have a variable shared by all instances of the class, similar to a "global" except that each derived class would get a new copy of the variable for its instances to share. For example:
/obj/base
    var/global/foo = 0 // Shared by all instances of /obj/base

/obj/base/derived1 // inherited "foo" shared by all instances of /obj/base/derived1
/obj/base/derived2 // inherited "foo" shared by all instances of /obj/base/derived2
/obj/base/derived2/derived3 // inherited "foo" shared by all instances of /obj/base/derived2/derived3

The documentation only mentions the reserved word "global" for the purpose of declaring shared variables, but the old reserved word "static" is still supported and appears to have the same function. Perhaps "static" could be used for this feature. If this would break too much existing code, a new reserved word would be needed.
On 10/31/00 6:52 am Paul Mikell wrote:
It would be useful if a class could have a variable shared by all instances of the class, similar to a "global" except that each derived class would get a new copy of the variable for its instances to share.


I ran into this desire recently too. The non-pretty workaround being to declare the global in each subclass manually.

Have you ever seen a notation for this in another system? I can't recall one.