Re: Safe reference counting cannot be implemented as a library

2015-12-13 Thread Martin Nowak via Digitalmars-d
On Monday, 7 December 2015 at 07:10:42 UTC, Sönke Ludwig wrote: I've very likely missed that part of the discussion - what were the reasons to not use "scope" for this? Yeah good point, it should be possible to reuse scope as method attribute. I just used @noescape as a placeholder for the

Re: Safe reference counting cannot be implemented as a library

2015-12-06 Thread Sönke Ludwig via Digitalmars-d
Am 01.11.2015 um 21:47 schrieb Martin Nowak: On 10/27/2015 12:41 PM, Andrei Alexandrescu wrote: - I'm not a fan of adding yet another attribute but as inference support is currently limited it seems we'd need an explicit attribute for public APIs. I've very likely missed that part of the

Re: Safe reference counting cannot be implemented as a library

2015-12-05 Thread deadalnix via Digitalmars-d
On Saturday, 5 December 2015 at 22:06:33 UTC, sclytrack wrote: On Monday, 2 November 2015 at 09:56:14 UTC, Ola Fosheim Grøstad wrote: On Sunday, 1 November 2015 at 22:04:51 UTC, deadalnix wrote: On Sunday, 1 November 2015 at 20:55:00 UTC, Martin Nowak wrote: On 11/01/2015 09:51 PM, Martin

Re: Safe reference counting cannot be implemented as a library

2015-12-05 Thread sclytrack via Digitalmars-d
On Monday, 2 November 2015 at 09:56:14 UTC, Ola Fosheim Grøstad wrote: On Sunday, 1 November 2015 at 22:04:51 UTC, deadalnix wrote: On Sunday, 1 November 2015 at 20:55:00 UTC, Martin Nowak wrote: On 11/01/2015 09:51 PM, Martin Nowak wrote:

Re: Safe reference counting cannot be implemented as a library

2015-11-02 Thread Ola Fosheim Grøstad via Digitalmars-d
On Sunday, 1 November 2015 at 22:04:51 UTC, deadalnix wrote: On Sunday, 1 November 2015 at 20:55:00 UTC, Martin Nowak wrote: On 11/01/2015 09:51 PM, Martin Nowak wrote: Any hint/numbers showing that this is actually useful? Also doesn't a good backend optimizer already fuse writes? Yes but

Re: Safe reference counting cannot be implemented as a library

2015-11-01 Thread deadalnix via Digitalmars-d
On Sunday, 1 November 2015 at 20:55:00 UTC, Martin Nowak wrote: On 11/01/2015 09:51 PM, Martin Nowak wrote: Any hint/numbers showing that this is actually useful? Also doesn't a good backend optimizer already fuse writes? Yes but you have this myth flying around that it is necessary for

Re: Safe reference counting cannot be implemented as a library

2015-11-01 Thread rsw0x via Digitalmars-d
On Sunday, 1 November 2015 at 22:36:46 UTC, Andrei Alexandrescu wrote: On 11/01/2015 03:51 PM, Martin Nowak wrote: On 10/27/2015 01:27 PM, Andrei Alexandrescu wrote: Unrelated, and a foreshadowing of the discussion on the lifetime mailing list: the compiler has ample opportunity to fuse

Re: Safe reference counting cannot be implemented as a library

2015-11-01 Thread rsw0x via Digitalmars-d
On Sunday, 1 November 2015 at 20:55:00 UTC, Martin Nowak wrote: On 11/01/2015 09:51 PM, Martin Nowak wrote: Any hint/numbers showing that this is actually useful? Also doesn't a good backend optimizer already fuse writes? AFAIK the fear of RC being too slow comes from C++'s shared_ptr's

Re: Safe reference counting cannot be implemented as a library

2015-11-01 Thread Andrei Alexandrescu via Digitalmars-d
On 11/1/15 5:52 PM, rsw0x wrote: On Sunday, 1 November 2015 at 22:36:46 UTC, Andrei Alexandrescu wrote: On 11/01/2015 03:51 PM, Martin Nowak wrote: On 10/27/2015 01:27 PM, Andrei Alexandrescu wrote: Unrelated, and a foreshadowing of the discussion on the lifetime mailing list: the compiler

Re: Safe reference counting cannot be implemented as a library

2015-11-01 Thread Martin Nowak via Digitalmars-d
On 10/27/2015 12:41 PM, Andrei Alexandrescu wrote: > It follows that if we want safe reference counting, there must be > language support for it. One possibility is to attach an attribute to > the class definition: > > @safe @rc class Widget { > ... > } Let's think about this more clearly

Re: Safe reference counting cannot be implemented as a library

2015-11-01 Thread Martin Nowak via Digitalmars-d
On 10/27/2015 01:27 PM, Andrei Alexandrescu wrote: > Unrelated, and a foreshadowing of the discussion on the lifetime mailing > list: the compiler has ample opportunity to fuse incs/decs together, so > the signatures of these functions is: > > void opInc(uint delta); > void opDec(uint delta);

Re: Safe reference counting cannot be implemented as a library

2015-11-01 Thread Martin Nowak via Digitalmars-d
On 11/01/2015 09:51 PM, Martin Nowak wrote: > Any hint/numbers showing that this is actually useful? Also doesn't a good backend optimizer already fuse writes?

Re: Safe reference counting cannot be implemented as a library

2015-11-01 Thread Andrei Alexandrescu via Digitalmars-d
On 11/01/2015 03:54 PM, Martin Nowak wrote: On 11/01/2015 09:51 PM, Martin Nowak wrote: Any hint/numbers showing that this is actually useful? Also doesn't a good backend optimizer already fuse writes? My understanding is that no, that won't happen in most patterns that matter. -- Andrei

Re: Safe reference counting cannot be implemented as a library

2015-11-01 Thread Andrei Alexandrescu via Digitalmars-d
On 11/01/2015 03:51 PM, Martin Nowak wrote: On 10/27/2015 01:27 PM, Andrei Alexandrescu wrote: Unrelated, and a foreshadowing of the discussion on the lifetime mailing list: the compiler has ample opportunity to fuse incs/decs together, so the signatures of these functions is: void opInc(uint

Re: Safe reference counting cannot be implemented as a library

2015-10-31 Thread sclytrack via Digitalmars-d
On Thursday, 29 October 2015 at 20:31:49 UTC, Zach the Mystic wrote: On Tuesday, 27 October 2015 at 18:10:18 UTC, deadalnix wrote: I've made the claim that we should implement reference counting as a library many time, so I think I should explicit my position. Indeed, RC require some level a

Re: Safe reference counting cannot be implemented as a library

2015-10-29 Thread Zach the Mystic via Digitalmars-d
On Tuesday, 27 October 2015 at 18:10:18 UTC, deadalnix wrote: I've made the claim that we should implement reference counting as a library many time, so I think I should explicit my position. Indeed, RC require some level a compiler support to be safe. That being said, the support does not

Re: Safe reference counting cannot be implemented as a library

2015-10-28 Thread David Nadlinger via Digitalmars-d
On Wednesday, 28 October 2015 at 11:21:17 UTC, Manu wrote: RC is okay-ish in C++11 (with rval references), although it could be much better, for instance, the type mangling/wrapping induced by this sort of library solution always leads to awkward situations, ie, 'this' pointer in a method is

Re: Safe reference counting cannot be implemented as a library

2015-10-28 Thread Manu via Digitalmars-d
On 28 October 2015 at 11:13, Walter Bright via Digitalmars-d wrote: > On 10/27/2015 11:10 AM, deadalnix wrote: >> >> I've made the claim that we should implement reference counting as a >> library >> many time, so I think I should explicit my position. Indeed, RC

Re: Safe reference counting cannot be implemented as a library

2015-10-28 Thread Manu via Digitalmars-d
On 28 October 2015 at 21:29, David Nadlinger via Digitalmars-d wrote: > On Wednesday, 28 October 2015 at 11:21:17 UTC, Manu wrote: >> >> RC is okay-ish in C++11 (with rval references), although it could be >> much better, for instance, the type mangling/wrapping

Re: Safe reference counting cannot be implemented as a library

2015-10-28 Thread Andrei Alexandrescu via Digitalmars-d
On 10/28/2015 04:13 AM, Jacob Carlborg wrote: On 2015-10-27 22:19, Andrei Alexandrescu wrote: That doesn't seem to be the case at all. -- Andrei I'm not a C++ or Rust expert. But I think that in Rust and with the new C++ guide lines the idea is to use reference counting pointers only for

Re: Safe reference counting cannot be implemented as a library

2015-10-28 Thread Paulo Pinto via Digitalmars-d
On Wednesday, 28 October 2015 at 03:55:25 UTC, deadalnix wrote: On Wednesday, 28 October 2015 at 01:13:16 UTC, Walter Bright wrote: It's not just safety. If the compiler knows that reference counting is going on, it can potentially elide a lot of the overhead. If it is faced with an

Re: Safe reference counting cannot be implemented as a library

2015-10-28 Thread Jacob Carlborg via Digitalmars-d
On 2015-10-27 22:50, Andrei Alexandrescu wrote: You can safely ignore the C++ part, the views are unsafe. I'd appreciate if you backed up your claim on Rust. -- Andrei Rust is unsafe as well, when you interface with unsafe code. -- /Jacob Carlborg

Re: Safe reference counting cannot be implemented as a library

2015-10-28 Thread Jacob Carlborg via Digitalmars-d
On 2015-10-28 07:07, Paulo Pinto wrote: However their exceptions work in a more RC friendly way. Swift doesn't support exceptions. And in Objective-C exceptions are like Errors in D. They should not be caught and the program should terminate. The error handling support that was added in

Re: Safe reference counting cannot be implemented as a library

2015-10-28 Thread Jacob Carlborg via Digitalmars-d
On 2015-10-27 22:19, Andrei Alexandrescu wrote: That doesn't seem to be the case at all. -- Andrei I'm not a C++ or Rust expert. But I think that in Rust and with the new C++ guide lines the idea is to use reference counting pointers only for owning resources. If you want to pass the data

Re: Safe reference counting cannot be implemented as a library

2015-10-28 Thread Walter Bright via Digitalmars-d
On 10/28/2015 7:58 AM, Andrei Alexandrescu wrote: On 10/28/2015 04:13 AM, Jacob Carlborg wrote: On 2015-10-27 22:19, Andrei Alexandrescu wrote: That doesn't seem to be the case at all. -- Andrei I'm not a C++ or Rust expert. But I think that in Rust and with the new C++ guide lines the idea

Re: Safe reference counting cannot be implemented as a library

2015-10-28 Thread Jacob Carlborg via Digitalmars-d
On 2015-10-28 09:50, Paulo Pinto wrote: Hence why I mentioned they are more RC friendly. Swift, because it doesn't have them. Objective-C, because termination is the only option so no need to worry about preserving counters. I was typing on the phone, so didn't want to provide the full

Re: Safe reference counting cannot be implemented as a library

2015-10-28 Thread Paulo Pinto via Digitalmars-d
On Wednesday, 28 October 2015 at 08:07:40 UTC, Jacob Carlborg wrote: On 2015-10-28 07:07, Paulo Pinto wrote: However their exceptions work in a more RC friendly way. Swift doesn't support exceptions. And in Objective-C exceptions are like Errors in D. They should not be caught and the

Re: Safe reference counting cannot be implemented as a library

2015-10-28 Thread Ola Fosheim Grøstad via Digitalmars-d
On Wednesday, 28 October 2015 at 06:07:12 UTC, Paulo Pinto wrote: Objective-C does elide refcounting, there are a few WWDC ARC sessions where it is mentioned. Same applies to Swift. Indeed, John McCall from Apple has already described how ARC works in these forums (astonishingly nobody felt

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Rikki Cattermole via Digitalmars-d
On 28/10/15 12:41 AM, Andrei Alexandrescu wrote: (Title is borrowed from Hans Boehm's famous "Threads cannot be implemented as a library", http://www.hpl.hp.com/techreports/2004/HPL-2004-209.pdf.) We want to implement safe reference counting in D, and the sentiment that it can be done in a

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Andrei Alexandrescu via Digitalmars-d
On 10/27/2015 07:57 AM, Manu via Digitalmars-d wrote: On 27 October 2015 at 21:41, Andrei Alexandrescu via Digitalmars-d wrote: It follows that if we want safe reference counting, there must be language support for it. One possibility is to attach an attribute to

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Manu via Digitalmars-d
On 27 October 2015 at 21:41, Andrei Alexandrescu via Digitalmars-d wrote: > > It follows that if we want safe reference counting, there must be language > support for it. One possibility is to attach an attribute to the class > definition: > > @safe @rc class Widget {

Safe reference counting cannot be implemented as a library

2015-10-27 Thread Andrei Alexandrescu via Digitalmars-d
(Title is borrowed from Hans Boehm's famous "Threads cannot be implemented as a library", http://www.hpl.hp.com/techreports/2004/HPL-2004-209.pdf.) We want to implement safe reference counting in D, and the sentiment that it can be done in a library (with no or minimal changes to the

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Manu via Digitalmars-d
On 27 October 2015 at 22:27, Andrei Alexandrescu via Digitalmars-d wrote: > On 10/27/2015 07:57 AM, Manu via Digitalmars-d wrote: >> >> On 27 October 2015 at 21:41, Andrei Alexandrescu via Digitalmars-d >> wrote: >>> >>> >>> It follows

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Andrei Alexandrescu via Digitalmars-d
On 10/27/15 11:59 AM, Jonathan M Davis wrote: On Tuesday, 27 October 2015 at 12:27:29 UTC, Andrei Alexandrescu wrote: Unrelated, and a foreshadowing of the discussion on the lifetime mailing list: What's the lifetime mailing list? To be created. -- Andrei

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Jonathan M Davis via Digitalmars-d
On Tuesday, 27 October 2015 at 12:27:29 UTC, Andrei Alexandrescu wrote: Unrelated, and a foreshadowing of the discussion on the lifetime mailing list: What's the lifetime mailing list? - Jonathan M Davis

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread deadalnix via Digitalmars-d
I've made the claim that we should implement reference counting as a library many time, so I think I should explicit my position. Indeed, RC require some level a compiler support to be safe. That being said, the support does not need to be specific to RC. On fact, my position is that the

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Joseph Rushton Wakeling via Digitalmars-d
On Tuesday, 27 October 2015 at 18:10:18 UTC, deadalnix wrote: The problem at hand here is escape analysis. The compiler must be able to ensure that a reference doesn't escape the RC mechanism in an uncontrolled manner. I'd like to add such mechanism to the language rather than bake in

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Namespace via Digitalmars-d
On Tuesday, 27 October 2015 at 20:19:42 UTC, PuglyWUgly wrote: Why care about this? Even Rust doesn't try to solve this problem...because it isn't really a problem in practice. In c++/rust code you use value/unique types 99.9% of the time, and reference counting is only for

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Jonathan M Davis via Digitalmars-d
On Tuesday, 27 October 2015 at 20:19:42 UTC, PuglyWUgly wrote: Why care about this? Even Rust doesn't try to solve this problem...because it isn't really a problem in practice. In c++/rust code you use value/unique types 99.9% of the time, and reference counting is only for

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread PuglyWUgly via Digitalmars-d
Why care about this? Even Rust doesn't try to solve this problem...because it isn't really a problem in practice. In c++/rust code you use value/unique types 99.9% of the time, and reference counting is only for shared/aliased objects. Reference counting == rare and unimportant

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Ola Fosheim Grøstad via Digitalmars-d
On Tuesday, 27 October 2015 at 20:19:42 UTC, PuglyWUgly wrote: Why care about this? Even Rust doesn't try to solve this problem...because it isn't really a problem in practice. In c++/rust code you use value/unique types 99.9% of the time, and reference counting is only for

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread rsw0x via Digitalmars-d
On Tuesday, 27 October 2015 at 20:41:49 UTC, Jonathan M Davis wrote: On Tuesday, 27 October 2015 at 20:19:42 UTC, PuglyWUgly wrote: Why care about this? Even Rust doesn't try to solve this problem...because it isn't really a problem in practice. In c++/rust code you use value/unique

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Andrei Alexandrescu via Digitalmars-d
On 10/27/2015 05:26 PM, rsw0x wrote: It has been a great success for Rust, I rarely ever see RC used anywhere in Rust code thanks to borrowing. The new C++ core guidelines are also heavily based on this cf. *_view types in GSL. You can safely ignore the C++ part, the views are unsafe. I'd

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread deadalnix via Digitalmars-d
On Tuesday, 27 October 2015 at 20:45:34 UTC, rsw0x wrote: if they're using shared_ptr all over the place, they're doing it wrong. shared_ptr is supposed to be a last resort According to Herb Sutter, it is a zero cost abstraction, not like these pesky GC that makes your program slow.

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread PuglyWUgly via Digitalmars-d
Really? I've seen tons of C++ code that's written using smart pointers with objects living on the heap which then get passed around all over the place. Yes there is lots of old C++ code that does this, largely because unique_ptr wasn't implementable until C++11 added R value refs and move

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread bitwise via Digitalmars-d
On Tuesday, 27 October 2015 at 20:41:49 UTC, Jonathan M Davis wrote: On Tuesday, 27 October 2015 at 20:19:42 UTC, PuglyWUgly wrote: [...] Really? I've seen tons of C++ code that's written using smart pointers with objects living on the heap which then get passed around all over the place.

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Andrei Alexandrescu via Digitalmars-d
On 10/27/2015 04:19 PM, PuglyWUgly wrote: Reference counting == rare and unimportant That doesn't seem to be the case at all. -- Andrei

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread rsw0x via Digitalmars-d
On Tuesday, 27 October 2015 at 21:50:15 UTC, Andrei Alexandrescu wrote: On 10/27/2015 05:26 PM, rsw0x wrote: It has been a great success for Rust, I rarely ever see RC used anywhere in Rust code thanks to borrowing. The new C++ core guidelines are also heavily based on this cf. *_view types

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread PuglyWUgly via Digitalmars-d
You can safely ignore the C++ part, the views are unsafe. I'd appreciate if you backed up your claim on Rust. -- Andrei I did a rough check of the Rust compiler source(from a copy I downloaded a couple months ago). I think the compiler is supposedly filled with old code, not sure if it is

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread deadalnix via Digitalmars-d
On Tuesday, 27 October 2015 at 21:50:15 UTC, Andrei Alexandrescu wrote: On 10/27/2015 05:26 PM, rsw0x wrote: It has been a great success for Rust, I rarely ever see RC used anywhere in Rust code thanks to borrowing. The new C++ core guidelines are also heavily based on this cf. *_view types

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread rsw0x via Digitalmars-d
On Tuesday, 27 October 2015 at 21:20:58 UTC, Andrei Alexandrescu wrote: On 10/27/2015 04:45 PM, rsw0x wrote: On Tuesday, 27 October 2015 at 20:41:49 UTC, Jonathan M Davis wrote: On Tuesday, 27 October 2015 at 20:19:42 UTC, PuglyWUgly wrote: Why care about this? Even Rust doesn't try to

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread PuglyWUgly via Digitalmars-d
Well perhaps D prefers the Swift route, with everyone ref counted & some compiler help. Nothing wrong with that I guess, I haven't been paying attention to what D is planning exactly.

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Andrei Alexandrescu via Digitalmars-d
On 10/27/2015 04:45 PM, rsw0x wrote: On Tuesday, 27 October 2015 at 20:41:49 UTC, Jonathan M Davis wrote: On Tuesday, 27 October 2015 at 20:19:42 UTC, PuglyWUgly wrote: Why care about this? Even Rust doesn't try to solve this problem...because it isn't really a problem in practice. In

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Jonathan M Davis via Digitalmars-d
On Tuesday, 27 October 2015 at 21:50:15 UTC, Andrei Alexandrescu wrote: On 10/27/2015 05:26 PM, rsw0x wrote: It has been a great success for Rust, I rarely ever see RC used anywhere in Rust code thanks to borrowing. The new C++ core guidelines are also heavily based on this cf. *_view types

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Walter Bright via Digitalmars-d
On 10/27/2015 11:10 AM, deadalnix wrote: I've made the claim that we should implement reference counting as a library many time, so I think I should explicit my position. Indeed, RC require some level a compiler support to be safe. That being said, the support does not need to be specific to RC.

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Walter Bright via Digitalmars-d
On 10/27/2015 9:03 AM, Andrei Alexandrescu wrote: On 10/27/15 11:59 AM, Jonathan M Davis wrote: What's the lifetime mailing list? To be created. -- Andrei And you'll be in it for life, so be sure you want to join :-)

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread deadalnix via Digitalmars-d
On Wednesday, 28 October 2015 at 01:13:16 UTC, Walter Bright wrote: It's not just safety. If the compiler knows that reference counting is going on, it can potentially elide a lot of the overhead. If it is faced with an arbitrary library solution, it only has a worm's eye view of it, and

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread rsw0x via Digitalmars-d
On Wednesday, 28 October 2015 at 03:55:25 UTC, deadalnix wrote: If I had to go about this, I'd rather see the introduction a scope(exit/success/failure) like mechanism for destructors rather than something ref counting specific. can you expand upon this?

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Sebastiaan Koppe via Digitalmars-d
On Tuesday, 27 October 2015 at 11:41:52 UTC, Andrei Alexandrescu wrote: The crux of the matter is modular typechecking. Consider the following example: // module widget.d @safe class Widget { void fun() { g_widget = this; } } static Widget g_widget; // end of module widget.d Now, once

Re: Safe reference counting cannot be implemented as a library

2015-10-27 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, 28 October 2015 at 02:08:18 UTC, Sebastiaan Koppe wrote: On Tuesday, 27 October 2015 at 11:41:52 UTC, Andrei Alexandrescu wrote: The crux of the matter is modular typechecking. Consider the following example: // module widget.d @safe class Widget { void fun() { g_widget =