Thread overview | |||||
---|---|---|---|---|---|
|
November 27, 2019 Safe and C++ | ||||
---|---|---|---|---|
| ||||
My understanding is that the current two big goals for D is: 1. To have 100% memory safe code as the default. 2. Being able to use large C++ frameworks. So, these would be two major features, but how are they going to interoperate? Right now ownership/borrowing seems to be discussed entirely in a pure D context, but that isn't very helpful if you want to use a C++ framework to build an application in D. So, basically what D needs is a way to annotate C++ interfaces with ownership-information so that you can do static analysis on safe D code that calls into C++ frameworks and objects. Static analysis requires knowledge of whether a C++ object is reference counted, owning, borrowing and what lifetime guarantees the safe D code has to obey by. Seems to me that working on ownership for D won't help much. You need something more abstract that also works for existing C++ code. If not, you end up with 2 languages: 1. An unsafe one for building with C++ frameworks. 2. A safe one for primarily building with D frameworks. Which seems a bit pointless, considering all the work involved. |
November 27, 2019 Re: Safe and C++ | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ola Fosheim Grøstad | On Wednesday, 27 November 2019 at 09:20:14 UTC, Ola Fosheim Grøstad wrote:
> My understanding is that the current two big goals for D is:
>
> 1. To have 100% memory safe code as the default.
>
> 2. Being able to use large C++ frameworks.
>
>
> So, these would be two major features, but how are they going to interoperate?
In the same way as C interfacing works with @safe (or @live). We annotate the C function header properly. When that is not enough, we make a @trusted wrapper that guards against misuse. Of course the impementation of the wrapper is still vurnerable.
|
November 27, 2019 Re: Safe and C++ | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dukc | On Wednesday, 27 November 2019 at 15:29:25 UTC, Dukc wrote:
> In the same way as C interfacing works with @safe (or @live). We annotate the C function header properly. When that is not enough, we make a @trusted wrapper that guards against misuse. Of course the impementation of the wrapper is still vurnerable.
There is one difference though, C-frameworks are often designed to be used from other languages.
Anyway, probably a good idea to make a list of C++ framworks that one has to be able to support and figure out what the requirements are.
|
Copyright © 1999-2021 by the D Language Foundation