Accessing static data of functions
Imperatorn
johan_forsberg_86 at hotmail.com
Tue Oct 19 17:08:41 UTC 2021
On Tuesday, 19 October 2021 at 17:04:32 UTC, Timon Gehr wrote:
> On 19.10.21 18:43, Imperatorn wrote:
>> On Tuesday, 19 October 2021 at 08:31:47 UTC, Mike Parker wrote:
>>> [...]
>>
>> I was actually thinking something similar. Have never heard of
>> that requirement before. You're serializing the object, not
>> the class, and the static variable doesn't belong to the
>> object (in many languages) but the class. I guess D looked at
>> Java? Have no evidence of that atm tho.
>>
>> That doesn't mean D *should* "do what Java does" ofc.
>
> This is about static variables at function scope. Java does not
> have static variables at function scope.
>
> string uniqueName(){
> static int id = 0; // this is the value that OP wants to
> preserve on reload
> return text("__tmp", id++);
> }
Ok, I know nothing about Java other than D got some inspiration
from it. What I do know is C#.
More information about the Digitalmars-d
mailing list