Accessing static data of functions

Mike Parker aldacron at gmail.com
Tue Oct 19 08:31:47 UTC 2021


On Tuesday, 19 October 2021 at 08:15:01 UTC, Ogi wrote:
>
> What are we talking about is not a game but an engine to be 
> used for making different games, potentially by people other 
> than me. So this is a limitation that the users will have to be 
> aware of and work around it, and failing to do so will result 
> in silent bugs in their code because there’s no way to enforce 
> it at compile time.

Personally, this isn't something I would expect, nor would I 
worry about it. Static variables in functions are generally there 
because they are scoped to that function, to be used within that 
function over the run time of the program. There shouldn't be any 
reason whatsoever for them to be accessible outside the function.

The idea that you are even considering serializing them is just a 
foreign concept to me. If I wanted to make something available to 
a serializer, I wouldn't declare it inside a function. I'd put it 
at module scope, or in an aggregate. I'm not saying no one would 
ever think of it (you obviously did), but in 25 years of 
following various online programming communities (C, Java, D, 
game development, etc.) I can't recall seeing anyone bring it up 
before now. I can't imagine it would be common enough to be an 
issue.


More information about the Digitalmars-d mailing list