C++ Logo

std-proposals

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

Thanks,
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:
http://coliru.stacked-crooked.com/a/3e5887dd4686e09b<https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fcoliru.stacked-crooked.com%2Fa%2F3e5887dd4686e09b&data=02%7C01%7Cmingxwa%40microsoft.com%7Cfc320d54d72b454bd0d008d6dd1eae7d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636939521180583210&sdata=XB9x0qra9tp67pP7oc4ezLouLbAzDd5f9mCN%2B5VVWMM%3D&reserved=0>
There is still a lot to optimize, but I don't see the need for gc.

Regards,
 Simon
P.S.
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.

Regards,
Andrew.

--
Std-Proposals mailing list
Std-Proposals_at_[hidden]<mailto:Std-Proposals_at_lists.isocpp.org>
http://lists.isocpp.org/mailman/listinfo.cgi/std-proposals<https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.isocpp.org%2Fmailman%2Flistinfo.cgi%2Fstd-proposals&data=02%7C01%7Cmingxwa%40microsoft.com%7Cfc320d54d72b454bd0d008d6dd1eae7d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636939521180593205&sdata=hb%2B5omAhLmI%2BuA5h0UCVUUubTh7UPmR5m2T6UST49pk%3D&reserved=0>

attached message:

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