Feedback desired for reflective enum library

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Feedback desired for reflective enum library

Boost - Dev mailing list
Hey,

I have a reflective enum library available here:
https://github.com/quicknir/wise_enum. I've been working on this on and off
for a couple of months. I've added features, dealt with various issues,
added docs, expanded support through 11-17 and as idiomatically as
possible. Overall I think the library is in nice shape (lacks unit tests
though, though I do already have a boost license for the code).

I feel like a reflective enum is just a very standard requirement in pretty
much every codebase I've ever worked on. Simply to be able to reasonably
log enums already makes it mandatory. It's also invaluable in
configuration, error message alerting, and many other places. There is
nothing for this in boost and actually there isn't really much of a
standard, standalone solution anyway. The closest is Better Enums (
http://aantron.github.io/better-enums/), but this has some major issues (it
doesn't actually create enums but rather enum-like classes, it targets 03).

So I think a library like this is needed and my implementation ticks off
the major requirements. Feedback on the overall design, any issues, any key
features it fails to meet, would be very useful. The library itself is very
small and simple so its easy to review. Once it seems like there's some
consensus on the core design I'm willing to do the work involved getting it
into boost (naming conventions/requirements, directory structure, tests,
boost-style docs, etc).

Note I'm not on the boost mailing list so please respond directly to this
email so I can see!

Cheers,

Nir

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Feedback desired for reflective enum library

Boost - Dev mailing list
Hi,

On 1/12/19 12:25 AM, Nir Friedman via Boost wrote:

> Hey,
>
> I have a reflective enum library available here:
> https://github.com/quicknir/wise_enum. I've been working on this on and off
> for a couple of months. I've added features, dealt with various issues,
> added docs, expanded support through 11-17 and as idiomatically as
> possible. Overall I think the library is in nice shape (lacks unit tests
> though, though I do already have a boost license for the code).
>
> I feel like a reflective enum is just a very standard requirement in pretty
> much every codebase I've ever worked on. Simply to be able to reasonably
> log enums already makes it mandatory. It's also invaluable in
> configuration, error message alerting, and many other places. There is
> nothing for this in boost and actually there isn't really much of a
> standard, standalone solution anyway. The closest is Better Enums (
> http://aantron.github.io/better-enums/), but this has some major issues (it
> doesn't actually create enums but rather enum-like classes, it targets 03).
>

I only read the readme and didn't look at the code -- is there a way to
easily convert existing enums without changing the code to put it all in
a `WISE_ENUM()` block?

Maybe that is an unrealistic goal but theoretically a drop in
replacement that could do something like:
```
enum colors_raw {
   RED = 0xff0000,
   GREEN = 0x00ff00,
};
#ifdef WISE_ENUM
CONVERT_TO_WISE_ENUM(colors_raw, colors);
#else
typdef enum colors_raw colors;
#endif
...
void some_function(colors background);
```

and just having to change the name of the raw enum temporarily,
declaring the new wise enum type and then reaping all the benefits w/o
chaning my whole code base.

> So I think a library like this is needed and my implementation ticks off
> the major requirements. Feedback on the overall design, any issues, any key
> features it fails to meet, would be very useful. The library itself is very
> small and simple so its easy to review. Once it seems like there's some
> consensus on the core design I'm willing to do the work involved getting it
> into boost (naming conventions/requirements, directory structure, tests,
> boost-style docs, etc).
>
> Note I'm not on the boost mailing list so please respond directly to this
> email so I can see!
>
> Cheers,
>
> Nir
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Feedback desired for reflective enum library

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
I had to fill in the subject for this manually, because of settings for the
mailing list. I really hope it ends up on the right thread. Apologies if it
doesn't.

Hi Geert,

There is an ADAPT macro, which is similar to your concept of
CONVERT_TO_WISE_ENUM. However, it does require listing the enumerators;
after all there's no way to find them out after the fact or else this
library wouldn't exist in the first place.

That said, I'm not quite sure what you mean by "changing your whole
codebase". To take advantage of wise enums, all you'd need to do is change
the original enum declaration to the wise enum macro. Everything else in
your codebase will continue to work exactly as before. No typedef
shenangians are necessary. Changing the original enum declaration is
exactly the same amount of work as writing an adapt macro, but you don't
have to maintain the list of enumerators twice. So I can't imagine a reason
to write things the way you have (unless you want a conditional build
dependency on WISE_ENUM but that seems unnecessary).

The ADAPT macro is designed to be use wise_enum functionality generically
with enumerators whose source you don't control, and therefore cannot
change the declaration.

Hope that clarifies things.

Cheers,

Nir

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Feedback desired for reflective enum library

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
On Sat, Jan 12, 2019, 1:20 AM Nir Friedman via Boost <[hidden email]
wrote:

> Hey,
>
> I have a reflective enum library available here:
> https://github.com/quicknir/wise_enum.


 Feedback on the overall design, any issues, any key
> features it fails to meet, would be very useful.
>


An interesting thought would be to provide an interface that mimics the
reflection TS. That way when reflection arrives code can be converted to
use it in a straightforward way.

>

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Feedback desired for reflective enum library

Boost - Dev mailing list
Sure, I'm open to such a thing. Although, I feel like there may be caveats
to that (i.e. whether the reflection TS interface is easy to use, whether
it's easy to emulate library-only, how likely it is to continue changing,
etc). Do you have a link to a paper that shows what the latest in the
reflection TS for enums looks like?

On Mon, Jan 28, 2019 at 6:04 PM David Sankel <[hidden email]> wrote:

>
>
> On Sat, Jan 12, 2019, 1:20 AM Nir Friedman via Boost <
> [hidden email] wrote:
>
>> Hey,
>>
>> I have a reflective enum library available here:
>> https://github.com/quicknir/wise_enum.
>
>
>  Feedback on the overall design, any issues, any key
>> features it fails to meet, would be very useful.
>>
>
>
> An interesting thought would be to provide an interface that mimics the
> reflection TS. That way when reflection arrives code can be converted to
> use it in a straightforward way.
>
>>

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Feedback desired for reflective enum library

Boost - Dev mailing list
On Tue, Feb 5, 2019, 2:00 PM Nir Friedman <[hidden email]> wrote:

> Sure, I'm open to such a thing. Although, I feel like there may be caveats
> to that (i.e. whether the reflection TS interface is easy to use, whether
> it's easy to emulate library-only, how likely it is to continue changing,
> etc). Do you have a link to a paper that shows what the latest in the
> reflection TS for enums looks like?
>

http://cplusplus.github.io/reflection-ts/draft.pdf

>

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost