Re: Improving DIP74: functions borrow by default, retain only if needed

2015-03-06 Thread John McCall via Digitalmars-d
On Saturday, 28 February 2015 at 02:55:14 UTC, Michel Fortin wrote: On 2015-02-27 23:11:55 +, deadalnix said: On Friday, 27 February 2015 at 23:06:26 UTC, Andrei Alexandrescu wrote: OK, so at least in theory autorelease pools are not necessary for getting ARC to work? -- Andrei ARC need

Re: Improving DIP74: functions borrow by default, retain only if needed

2015-02-28 Thread Zach the Mystic via Digitalmars-d
On Friday, 27 February 2015 at 21:21:08 UTC, Andrei Alexandrescu wrote: On 2/27/15 1:02 PM, Michel Fortin wrote: On 2015-02-27 20:34:08 +, Steven Schveighoffer said: void main() { C2 c2 = new C2; c2.c = new C; foo(c2.c, c2); } Still same question. The issue here is how do you

Re: Improving DIP74: functions borrow by default, retain only if needed

2015-02-27 Thread Michel Fortin via Digitalmars-d
On 2015-02-27 23:11:55 +, deadalnix said: On Friday, 27 February 2015 at 23:06:26 UTC, Andrei Alexandrescu wrote: OK, so at least in theory autorelease pools are not necessary for getting ARC to work? -- Andrei ARC need them, this is part of the spec. You can have good RC without them

Improving DIP74: functions borrow by default, retain only if needed

2015-02-27 Thread Andrei Alexandrescu via Digitalmars-d
DIP74's function call protocol for RCOs has the caller insert opAddRef for each RCO passed by value. Then the callee has the responsibility to call opRelease (or defer that to another entity). This choice of protocol mimics the constructor/destructor protocol and probably shows our C++ bias.

Re: Improving DIP74: functions borrow by default, retain only if needed

2015-02-27 Thread Zach the Mystic via Digitalmars-d
On Friday, 27 February 2015 at 18:24:27 UTC, Andrei Alexandrescu wrote: DIP74's function call protocol for RCOs has the caller insert opAddRef for each RCO passed by value. Then the callee has the responsibility to call opRelease (or defer that to another entity). This choice of protocol

Re: Improving DIP74: functions borrow by default, retain only if needed

2015-02-27 Thread H. S. Teoh via Digitalmars-d
On Fri, Feb 27, 2015 at 10:24:26AM -0800, Andrei Alexandrescu via Digitalmars-d wrote: DIP74's function call protocol for RCOs has the caller insert opAddRef for each RCO passed by value. Then the callee has the responsibility to call opRelease (or defer that to another entity). This choice of

Re: Improving DIP74: functions borrow by default, retain only if needed

2015-02-27 Thread Steven Schveighoffer via Digitalmars-d
On 2/27/15 3:30 PM, Steven Schveighoffer wrote: void main() { C c = new C; // ref counted class C2 c2 = new C2; // another ref counted class c2.c = c; foo(c, c2); } Bleh, that was dumb. void main() { C2 c2 = new C2; c2.c = new C; foo(c2.c, c2); } Still same question. The issue here

Re: Improving DIP74: functions borrow by default, retain only if needed

2015-02-27 Thread Steven Schveighoffer via Digitalmars-d
On 2/27/15 1:24 PM, Andrei Alexandrescu wrote: DIP74's function call protocol for RCOs has the caller insert opAddRef for each RCO passed by value. Then the callee has the responsibility to call opRelease (or defer that to another entity). This choice of protocol mimics the

Re: Improving DIP74: functions borrow by default, retain only if needed

2015-02-27 Thread Andrei Alexandrescu via Digitalmars-d
On 2/27/15 1:02 PM, Michel Fortin wrote: On 2015-02-27 20:34:08 +, Steven Schveighoffer said: On 2/27/15 3:30 PM, Steven Schveighoffer wrote: void main() { C c = new C; // ref counted class C2 c2 = new C2; // another ref counted class c2.c = c; foo(c, c2); } Bleh, that was dumb. void

Re: Improving DIP74: functions borrow by default, retain only if needed

2015-02-27 Thread Michel Fortin via Digitalmars-d
On 2015-02-27 20:34:08 +, Steven Schveighoffer said: On 2/27/15 3:30 PM, Steven Schveighoffer wrote: void main() { C c = new C; // ref counted class C2 c2 = new C2; // another ref counted class c2.c = c; foo(c, c2); } Bleh, that was dumb. void main() { C2 c2 = new C2; c2.c =

Re: Improving DIP74: functions borrow by default, retain only if needed

2015-02-27 Thread Andrei Alexandrescu via Digitalmars-d
On 2/27/15 12:34 PM, Steven Schveighoffer wrote: On 2/27/15 3:30 PM, Steven Schveighoffer wrote: void main() { C c = new C; // ref counted class C2 c2 = new C2; // another ref counted class c2.c = c; foo(c, c2); } Bleh, that was dumb. void main() { C2 c2 = new C2; c2.c = new C;

Re: Improving DIP74: functions borrow by default, retain only if needed

2015-02-27 Thread Zach the Mystic via Digitalmars-d
On Friday, 27 February 2015 at 20:30:20 UTC, Steven Schveighoffer wrote: OK, I found the offending issue. It's when you pass a parameter, the only reference holding onto it may be also passed as well. Something like: void foo(C c, C2 c2) { c2.c = null; // this destroys 'c' unless you

Re: Improving DIP74: functions borrow by default, retain only if needed

2015-02-27 Thread Steven Schveighoffer via Digitalmars-d
On 2/27/15 4:15 PM, Andrei Alexandrescu wrote: On 2/27/15 12:34 PM, Steven Schveighoffer wrote: On 2/27/15 3:30 PM, Steven Schveighoffer wrote: void main() { C c = new C; // ref counted class C2 c2 = new C2; // another ref counted class c2.c = c; foo(c, c2); } Bleh, that was dumb. void

Re: Improving DIP74: functions borrow by default, retain only if needed

2015-02-27 Thread Zach the Mystic via Digitalmars-d
On Friday, 27 February 2015 at 21:21:08 UTC, Andrei Alexandrescu wrote: On 2/27/15 1:02 PM, Michel Fortin wrote: On 2015-02-27 20:34:08 +, Steven Schveighoffer said: On 2/27/15 3:30 PM, Steven Schveighoffer wrote: void main() { C c = new C; // ref counted class C2 c2 = new C2; //

Re: Improving DIP74: functions borrow by default, retain only if needed

2015-02-27 Thread Andrei Alexandrescu via Digitalmars-d
On 2/27/15 2:46 PM, Michel Fortin wrote: On 2015-02-27 21:33:51 +, Steven Schveighoffer said: I believe autorelease pools are not needed for ARC, but are maintained because much Objective-C code contains MRC, and that protocol needs to be supported. Exactly. OK, so at least in theory

Re: Improving DIP74: functions borrow by default, retain only if needed

2015-02-27 Thread deadalnix via Digitalmars-d
On Friday, 27 February 2015 at 23:06:26 UTC, Andrei Alexandrescu wrote: On 2/27/15 2:46 PM, Michel Fortin wrote: On 2015-02-27 21:33:51 +, Steven Schveighoffer said: I believe autorelease pools are not needed for ARC, but are maintained because much Objective-C code contains MRC, and that

Re: Improving DIP74: functions borrow by default, retain only if needed

2015-02-27 Thread Michel Fortin via Digitalmars-d
On 2015-02-27 21:33:51 +, Steven Schveighoffer said: I believe autorelease pools are not needed for ARC, but are maintained because much Objective-C code contains MRC, and that protocol needs to be supported. Exactly. -- Michel Fortin michel.for...@michelf.com http://michelf.com/