RFR: 8247912: Make narrowOop a scoped enum
Kim Barrett
kim.barrett at oracle.com
Mon Sep 21 09:18:03 UTC 2020
> On Sep 21, 2020, at 4:34 AM, Roman Kennke <rkennke at openjdk.java.net> wrote:
>
> On Mon, 21 Sep 2020 04:01:34 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>
>> […]
>
> I'm not convinced. This reduces readability of the code for little gain IMO. A typedef is the logical C++ construct for
> something like a narrowOop. An enum class is not, or at least I don't see it. How's a narrowOop an enumeration? The
> next time somebody uninitiated comes across this declaration, this is going to cause headscratching. I'd rather avoid
> that.
This is a normal and well-established use of scoped enums as type-safe
integral-like values. Examples from the C++17 Standard include std::byte and
std::align_val_t. I've also seen type-safe integer arithmetic done this way,
eliminating that nasty implicit promotion and conversion stuff that can get
one into so much trouble. I'm sure I can produce more examples if needed.
More information about the shenandoah-dev
mailing list