Endorsement, review manager sought for Boost.Describe

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Endorsement, review manager sought for Boost.Describe

Boost - Dev mailing list
I would like to submit a C++14 reflection library, Describe, to Boost and
I'm looking for endorsements and a review manager. The library is at
https://github.com/pdimov/describe and the documentation is at
https://pdimov.github.io/describe/doc/html/describe.html. Some examples of
what the library enables are given at
https://pdimov.github.io/describe/doc/html/describe.html#examples.

The purpose of Describe is to establish a standard way of annotating
(describing) user-defined types (enums, structs and classes), so that types
can be described once, and then their descriptions can be used from other
libraries. At the moment, the practice is for each library to invent its own
ad-hoc annotation/description mechanism.


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

Re: Endorsement, review manager sought for Boost.Describe

Boost - Dev mailing list
On Thu, Sep 24, 2020 at 8:43 AM Peter Dimov via Boost
<[hidden email]> wrote:
> I would like to submit a C++14 reflection library, Describe, to Boost and
> I'm looking for endorsements and a review manager.

Looks pretty solid and useful, although the C++14 requirement is a
bummer but I understand it can't be helped. This counts as my
endorsement.

Regards

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

Re: Endorsement, review manager sought for Boost.Describe

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
On 9/24/2020 11:43 AM, Peter Dimov via Boost wrote:

> I would like to submit a C++14 reflection library, Describe, to Boost
> and I'm looking for endorsements and a review manager. The library is at
> https://github.com/pdimov/describe and the documentation is at
> https://pdimov.github.io/describe/doc/html/describe.html. Some examples
> of what the library enables are given at
> https://pdimov.github.io/describe/doc/html/describe.html#examples.
>
> The purpose of Describe is to establish a standard way of annotating
> (describing) user-defined types (enums, structs and classes), so that
> types can be described once, and then their descriptions can be used
> from other libraries. At the moment, the practice is for each library to
> invent its own ad-hoc annotation/description mechanism.

I will endorse the library. I have had an interest in C++ reflection for
a long time.


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

Re: Endorsement, review manager sought for Boost.Describe

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
> Gesendet: Donnerstag, 24. September 2020 um 17:43 Uhr
> Von: "Peter Dimov via Boost" <[hidden email]>
>
> I would like to submit a C++14 reflection library, Describe, to Boost and
> I'm looking for endorsements and a review manager. The library is at

I'd also like to endorse this library and am looking forward to replace
some of our home grown solutions with this.
In order to become the de-facto standard way to annotate custom types,
it would be great, if the dependency on mp11 could be removed, but it
would certainly be useful to us with that dependency too.

Best

Mike

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

Re: Endorsement, review manager sought for Boost.Describe

Boost - Dev mailing list
Mike wrote:

> In order to become the de-facto standard way to annotate custom types, it
> would be great, if the dependency on mp11 could be removed, but it would
> certainly be useful to us with that dependency too.

Annotating the types should work without Mp11; <boost/describe/enum.hpp> and
<boost/describe/class.hpp> don't include any Mp11 headers. Only the use of
the describe_* primitives needs Mp11.


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

Re: Endorsement, review manager sought for Boost.Describe

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
On 9/24/20 11:43 pm, Peter Dimov via Boost wrote:

> I would like to submit a C++14 reflection library, Describe, to Boost and I'm looking for
> endorsements and a review manager. The library is at https://github.com/pdimov/describe 
> and the documentation is at https://pdimov.github.io/describe/doc/html/describe.html. Some
> examples of what the library enables are given at
> https://pdimov.github.io/describe/doc/html/describe.html#examples.
>
> The purpose of Describe is to establish a standard way of annotating (describing)
> user-defined types (enums, structs and classes), so that types can be described once, and
> then their descriptions can be used from other libraries. At the moment, the practice is
> for each library to invent its own ad-hoc annotation/description mechanism.

+1. I love this. I think this will be a great addition to the Boost libraries.

Regards,
--
Joel

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

Re: Endorsement, review manager sought for Boost.Describe

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
On Fri, 25 Sep 2020 at 01:43, Peter Dimov via Boost <[hidden email]>
wrote:

> I would like to submit a C++14 reflection library, Describe, to Boost and
> I'm looking for endorsements and a review manager.
>

Describe looks pleasant. A short note in the documentation on how it
compares to two existing methods in Boost, Fusion and Hana, maybe helpful.

--Matt.

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

Re: Endorsement, review manager sought for Boost.Describe

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
Em qui., 24 de set. de 2020 às 12:43, Peter Dimov via Boost
<[hidden email]> escreveu:
> The purpose of Describe is to establish a standard way of annotating
> (describing) user-defined types (enums, structs and classes), so that types
> can be described once, and then their descriptions can be used from other
> libraries. At the moment, the practice is for each library to invent its own
> ad-hoc annotation/description mechanism.

Hi Peter,

could you consider using "compile-time strings" such as Hana's? I
don't have much use for a const char* in TMP algorithms. I coded a
gperf-like algorithm earlier this year and the only thing that enabled
me to do so were Hana strings: https://pastebin.com/5gbWPeSk

Another use I've found for Hana-like strings was avoiding allocation
on object keys for json::partial::scanf(). Both algorithms can be
adapted to JSON serialization code that integrates with
serialization/reflection libraries, but only if I have something more
than char*.

You don't need to replace the current `name` member. You could maybe
just add an additional member? Maybe controlled through macros so you
don't force unwanted dependencies on everybody?

OTOH, if you're going to enable Hana integration behind a preprocessor
macro, maybe you could as well just forward on doing a complete
boost::hana::accessors integration. Not sure what is the right approach
here.

Hana is such a great TMP library that you risk turning it into your
default go-to for any complex TMP problem once you get your head
around it.

Honestly, if I can't implement the algorithms described above, I
wouldn't use this library at all (I can already do them on Boost.Hana
and they work today). One usually annotate/describe structs in Hana
using code such as:

```cpp
namespace ns {
    struct Person {
        explicit Person(std::string const& name, int age)
            : name_(name), age_(age)
        { }
        std::string const& get_name() const { return name_; }
        int get_age() const { return age_; }
    private:
        std::string name_;
        int age_;
    };
}
BOOST_HANA_ADAPT_ADT(ns::Person,
    (name, [](ns::Person const& p) { return p.get_name(); }),
    (age, [](ns::Person const& p) { return p.get_age(); })
);
```

You can see full examples at
<https://www.boost.org/doc/libs/1_72_0/libs/hana/doc/html/group__group-Struct.html#ga141761435a7826b3cbe646b4f59eaf0a>.


--
Vinícius dos Santos Oliveira
https://vinipsmaker.github.io/

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

Re: Endorsement, review manager sought for Boost.Describe

Boost - Dev mailing list
Vinícius dos Santos Oliveira wrore:
> Hi Peter,
>
> could you consider using "compile-time strings" such as Hana's? I don't
> have much use for a const char* in TMP algorithms.

The descriptor strings are "compile-time". This, for instance, works.

#include <boost/describe.hpp>
#include <boost/mp11.hpp>
#include <cstddef>
#include <array>

using namespace boost::describe;
using namespace boost::mp11;

enum E
{
    v1
};

BOOST_DESCRIBE_ENUM(E, v1)

constexpr std::size_t strlen_( char const * s )
{
    std::size_t n = 0;
    while( *s++ ) ++n;
    return n;
}

constexpr std::size_t hash_value( char const * s )
{
    std::size_t n = 5381;
    while( *s ) n = n * 31 + static_cast<unsigned char>( *s++ );
    return n;
}

template<class D> constexpr auto name_as_array()
{
    constexpr auto n = strlen_(D::name);

    std::array<char, n> r{};

    for( std::size_t i = 0; i < n; ++i )
    {
        r[i] = D::name[i];
    }

    return r;
}

using D = mp_first< describe_enumerators<E> >;

constexpr auto x1 = strlen_( D::name );
constexpr auto x2 = hash_value( D::name );
constexpr auto x3 = name_as_array<D>();


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

Re: Endorsement, review manager sought for Boost.Describe

Boost - Dev mailing list
Em qui., 24 de set. de 2020 às 19:13, Peter Dimov <[hidden email]> escreveu:
> This, for instance, works. [...]

Nice. Will take a deeper look later. Thanks.


--
Vinícius dos Santos Oliveira
https://vinipsmaker.github.io/

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

Re: Endorsement, review manager sought for Boost.Describe

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
> Vinícius dos Santos Oliveira wrore:
> > Hi Peter,
> >
> > could you consider using "compile-time strings" such as Hana's? I don't
> > have much use for a const char* in TMP algorithms.
>
> The descriptor strings are "compile-time". This, for instance, works.
...

Here's how you can get a Hana string:

#include <boost/describe.hpp>
#include <boost/mp11.hpp>
#include <boost/hana.hpp>
#include <cstddef>

using namespace boost::describe;
using namespace boost::mp11;

enum E
{
    v1
};

BOOST_DESCRIBE_ENUM(E, v1)

constexpr std::size_t strlen_( char const * s )
{
    std::size_t n = 0;
    while( *s++ ) ++n;
    return n;
}

template<class D, std::size_t... I> constexpr auto to_string_impl(
index_sequence<I...> )
{
    return boost::hana::string_c<D::name[I]...>;
}

template<class D> constexpr auto to_string()
{
    return to_string_impl<D>( make_index_sequence<strlen_(D::name)>() );
}

using D = mp_first< describe_enumerators<E> >;

constexpr auto st = to_string<D>();

#include <typeinfo>
#include <cstdio>

int main()
{
    std::printf( "%s\n", typeid(st).name() );
}


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