November 01, 2014 Re: D wrapper classes leak memory. Next steps? | ||||
---|---|---|---|---|
| ||||
Posted in reply to eles | Am Fri, 31 Oct 2014 13:16:15 +0000 schrieb "eles" <eles@eles.com>: > On Friday, 31 October 2014 at 10:06:51 UTC, Ola Fosheim Grøstad wrote: > > On Friday, 31 October 2014 at 09:58:41 UTC, ketmar via Digitalmars-d wrote: > >> if you have something concrete in mind, write ER or forum post, so we can destroy it. ;-) > > > - make uniqe_ptr a language builtin > > I would go with this by default for all pointers/references. > > Something that I read here: > > https://news.ycombinator.com/item?id=7650917 > > My feeling too. > > If you need more owners for a resource, then explicitly ask for. In case of a onDraw callback the object will be passed as a parameter into the drawing function. unique_ptr doesn't solve this. In the particular case of callbacks from C libraries that give us opaque "context" pointers we want to wrap with D classes we can use either of: - reference counted object (doesn't exist in D) - unique_ptr (requires "scope" to be implemented) - Scoped ? Maybe Scoped wasn't explored enough for callbacks in GtkD. But yeah, you'd still need one of the others to deal with external resources where the lifetime is not a specific stack frame. -- Marco |
November 01, 2014 Re: D wrapper classes leak memory. Next steps? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marco Leise Attachments: | On Sat, 1 Nov 2014 19:10:15 +0100
Marco Leise via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> - reference counted object (doesn't exist in D)
but it exists! and with a size of machine pointer! i swear it exists, i'm using it!
|
Copyright © 1999-2021 by the D Language Foundation