C++ Logo


Advanced search

Re: Fwd: Proposal of Handles (draft 2)

From: Mingxin Wang <mingxwa_at_[hidden]>
Date: Mon, 20 May 2019 13:12:25 +0000
Hi Simon and Andrew,

I am not sure if you saw my previous comments to the proposal after it was floated on the google forum but has not been posted in this thread. Please find my previous response in the attachments if needed.

I think the motivating example has certain significance as it may save engineering costs when extendibility is more important than performance. However, I thought there could be a better solution other than runtime automatic GC, and I came up with a template library with some informal wording. I am sorry the links to the implementation in the previous response are broken because the code has been updated. Please refer to the new links below:

The “Instant GC” library: https://github.com/wmx16835/my-stl/blob/da6c492ebb65fc8d83671aa2ecc4cadc51acdf06/src/test/p1649/instant_gc.h#L45-L57
Sample implementation for the motivating example: https://github.com/wmx16835/my-stl/blob/da6c492ebb65fc8d83671aa2ecc4cadc51acdf06/src/test/p1649/test_instant_gc.cc#L29-L54

Mingxin Wang

From: Std-Proposals <std-proposals-bounces_at_[hidden]cpp.org> On Behalf Of Simon Kraemer via Std-Proposals
Sent: Monday, May 20, 2019 8:28 PM
To: std-proposals_at_lists.isocpp.org
Cc: Simon Kraemer <sikraemer_at_[hidden]>
Subject: Re: [std-proposals] Fwd: Proposal of Handles (draft 2)

Hello Andrew,

after reading through your proposal I found some things that don't seem quite right.

While I can understand the need of a garbage collector in some use cases, the one featured in the proposal is one of the less convincing examples.
The code is generating a lot of objects that are not needed anywhere just to throw them away some time later.
For me, this is an anti-pattern.

Using a Dungeon class as owner for the rooms of the Dungeon, rather than just defining ownership by the room self-referencing each other, you can implement your example with an recursive approach:
There is still a lot to optimize, but I don't see the need for gc.

1. Your main-function uses 'uniform_real_distribution' instead of 'uniform_int_distribution'. This won't compile for size_t.
2. You are initializing the Mersenne-Twister generators with 'std::mt19937 gen(std::random_device{});' which should be 'std::mt19937 gen(std::random_device{}());' (parenthesis)

Am Fr., 17. Mai 2019 um 11:26 Uhr schrieb Andrew Tomazos via Std-Proposals <std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>>:
Oops, this was supposed to go to std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]> not std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>
---------- Forwarded message ---------
From: Andrew Tomazos <andrewtomazos_at_[hidden]<mailto:andrewtomazos_at_[hidden]>>
Date: Wed, May 15, 2019 at 9:20 PM
Subject: Proposal of Handles (draft 2)
To: <std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>>

Please find attached a working draft of:

     Proposal of Handles

Feedback appreciated.


Std-Proposals mailing list

attached message:

Received on 2019-05-20 08:14:12