Re: Reference counting questions

2011-07-25 Thread Johannes Pfau
Andrej Mitrovic wrote: >I'm don't understand why this code calls the dtor before it calls the >ctor: > >import std.stdio; >import std.typecons; > >void main() >{ >auto wrap1 = Wrapper(1); >} > >void free(ref int _payload) >{ >writeln("dealloc"); >_payload = 0; >} > >struct Wrapper >{ >

Re: Reference counting questions

2011-07-24 Thread Andrej Mitrovic
I'm don't understand why this code calls the dtor before it calls the ctor: import std.stdio; import std.typecons; void main() { auto wrap1 = Wrapper(1); } void free(ref int _payload) { writeln("dealloc"); _payload = 0; } struct Wrapper { struct Payload { int _payloa

Re: Reference counting questions

2011-07-23 Thread Johannes Pfau
Jesse Phillips wrote: >I don't really think stdio is the place to see modern D ref counting. >The container class has an Array which is built to use RefCounted. I >had tried my and at explaining how to use it: http://stackoverflow.com/ >questions/4632355/making-a-reference-counted-object-in-d-using

Re: Reference counting questions

2011-07-23 Thread Johannes Pfau
Jesse Phillips wrote: >I don't really think stdio is the place to see modern D ref counting. >The container class has an Array which is built to use RefCounted. I >had tried my and at explaining how to use it: http://stackoverflow.com/ >questions/4632355/making-a-reference-counted-object-in-d-using

Re: Reference counting questions

2011-07-22 Thread Jesse Phillips
I don't really think stdio is the place to see modern D ref counting. The container class has an Array which is built to use RefCounted. I had tried my and at explaining how to use it: http://stackoverflow.com/ questions/4632355/making-a-reference-counted-object-in-d-using- refcountedt/4635050#46

Reference counting questions

2011-07-22 Thread Johannes Pfau
I have some problems understanding the reference counting code in std.stdio. The reduced code my questions refer to is here: https://gist.github.com/1099229 (ignore the not-working struct default constructor, that's just to simplify the code) in line 5: why is 'refs' initialized to 'uint.max / 2'?