Date: Sat, 20 Apr 2024 10:12:41 +0200
I find reflection on attributes somewhat problematic, because
attributes have arguments
- Any solution to reflect on attributes should consider the arguments
- Any general solution to reflect on attributes should work in the general
case, not just for standard attributes.
- In the general case, arguments cannot be reflected because they are
token soup with complete disregard for C++ grammar.
There is also the impact on the whole attribute ignorability imbroglio.
This leaves a few options for standard attributes:
- Make it an opaque thing that you can copy but not inspect. This is close
to what you propose, but the discussion about what happens to arguments
should still be present.
I wonder if something like
[[nodiscard_if(std::meta::is_nodiscard(some_reflection))]] isn't sufficient
for your use case.
Given the limited number of standard attributes, I think it would be fine
to have individual queries for them, and there arguments (
std::meta::nodiscard_reason)
- Find a way for existing attributes to correspond to a strongly typed
object that can then be queried for arguments etc
- Introduce a completely different mechanism akin to decorators in other
languages. This is useful but I haven't figured a way to make existing
attributes work with that.
On Sat, Apr 20, 2024 at 4:53 AM Aurelien Cassagnes via SG7 <
sg7_at_[hidden]> wrote:
> Fleshed out the proposal draft and it's available for feedback at
> https://github.com/zebullax/wg21/blob/main/generated/proposal.pdf
> --
> SG7 mailing list
> SG7_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/sg7
>
attributes have arguments
- Any solution to reflect on attributes should consider the arguments
- Any general solution to reflect on attributes should work in the general
case, not just for standard attributes.
- In the general case, arguments cannot be reflected because they are
token soup with complete disregard for C++ grammar.
There is also the impact on the whole attribute ignorability imbroglio.
This leaves a few options for standard attributes:
- Make it an opaque thing that you can copy but not inspect. This is close
to what you propose, but the discussion about what happens to arguments
should still be present.
I wonder if something like
[[nodiscard_if(std::meta::is_nodiscard(some_reflection))]] isn't sufficient
for your use case.
Given the limited number of standard attributes, I think it would be fine
to have individual queries for them, and there arguments (
std::meta::nodiscard_reason)
- Find a way for existing attributes to correspond to a strongly typed
object that can then be queried for arguments etc
- Introduce a completely different mechanism akin to decorators in other
languages. This is useful but I haven't figured a way to make existing
attributes work with that.
On Sat, Apr 20, 2024 at 4:53 AM Aurelien Cassagnes via SG7 <
sg7_at_[hidden]> wrote:
> Fleshed out the proposal draft and it's available for feedback at
> https://github.com/zebullax/wg21/blob/main/generated/proposal.pdf
> --
> SG7 mailing list
> SG7_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/sg7
>
Received on 2024-04-20 08:13:00