Type global initilizers must be constant

BlitzMax Forums/BlitzMax Programming/Type global initilizers must be constant

Sorry to quote myself guys ...

@Robert: That's exactly what I said. Or tried to say:
When declaring a global variable inside a type, comes the question of where to put that "MyVar = New MyType" statement.
and to me the solution seems simple:
I'd like to advocate in putting it right before the type declaration.


@Dreamora: This isn't a pleasing solution as I said:
Or worse, always check inside the MyType instances if the list is allocated and if not do it.

Simply because it adds an overhead. Sure this is mostly peanuts, but why having to live with it if the problem can be fixed easily by allowing non constant initializers? Also it simply makes the code less elegant and more error prone as you'll need to check g_List against Null every time you access it. In this case you'd better wrap that in a getter, which actually is a common idiom in other languages to enforce the singleton pattern
Type MyType
    Global g_List:TList
    Function GetGlobalList:TList()
        If g_list = Null
           g_list = New TList
        EndIf
        Return g_List
    End Function
    Method New()
        GetGlobalList().AddLast(Self)
    End Method
    Method Delete()
        GetGlobalList().Remove(Self)
    End Method
End Type

But that's another additional overhead. And I'd like to have the choice not to have this overhead. I think this is perfectly legitimate, especially when considering there is apparently no real problem in fixing this. If there is I'd simply like to know what it is.