Date: Fri, 28 Feb 2025 16:23:31 +0000
Hi,
I might have a use case for an environment query in sender/receiver that is not a forwarding query. While looking into the implementation of various get_env() I came across two cases that just look wrong to me:
1. While default-impls::get-env only forwards forwarding queries (see https://eel.is/c++draft/exec.snd.expos#35), impls-for<when_all_t>::get-env seems to forward all queries: https://eel.is/c++draft/exec.when.all#6.3. I would expect when_all() to not forward non-forwarding queries.
2. The default implementation of as_awaitable() only makes forwarding queries available (see https://eel.is/c++draft/exec.as.awaitable#4.4). I would expect it to forward all queries.
Usually as_awaitable() is not visible to users of a coroutine. To my understanding it is intended to be used in await_transform(). Therefore, to me it is surprising that non-forwarding queries are not available in a coroutine body. Consider
co_await read_env(get_non_forwarding);
Even if the environment of the coroutine promise supports the get_non_forwarding query, the above read_env() expression would not be able to access the value (even though nothing is between me and the coroutine). Note that for my own sender I could customize as_awaitable() and get access to my non-forwarding query which is even more confusing.
Is this all intended?
Regards,
Daniel
I might have a use case for an environment query in sender/receiver that is not a forwarding query. While looking into the implementation of various get_env() I came across two cases that just look wrong to me:
1. While default-impls::get-env only forwards forwarding queries (see https://eel.is/c++draft/exec.snd.expos#35), impls-for<when_all_t>::get-env seems to forward all queries: https://eel.is/c++draft/exec.when.all#6.3. I would expect when_all() to not forward non-forwarding queries.
2. The default implementation of as_awaitable() only makes forwarding queries available (see https://eel.is/c++draft/exec.as.awaitable#4.4). I would expect it to forward all queries.
Usually as_awaitable() is not visible to users of a coroutine. To my understanding it is intended to be used in await_transform(). Therefore, to me it is surprising that non-forwarding queries are not available in a coroutine body. Consider
co_await read_env(get_non_forwarding);
Even if the environment of the coroutine promise supports the get_non_forwarding query, the above read_env() expression would not be able to access the value (even though nothing is between me and the coroutine). Note that for my own sender I could customize as_awaitable() and get access to my non-forwarding query which is even more confusing.
Is this all intended?
Regards,
Daniel
Received on 2025-02-28 16:23:38