Repository navigation
Capy types need renaming #395
Copy link
Copy link
Closed
Description
Capy's viability goes beyond I/O. Many of our types are centered around I/O. Let's fix that.
Survey of the land:
Public types
- IoAwaitable — concept, include/boost/capy/concept/io_awaitable.hpp:127
- IoAwaitableRange — concept, include/boost/capy/concept/io_awaitable.hpp:155
- IoRunnable — concept, include/boost/capy/concept/io_runnable.hpp:91
- io_result — alias template for std::tuple<std::error_code, Ts...>, include/boost/capy/io_result.hpp:52
- io_task — alias template for task<io_result<Ts...>>, include/boost/capy/io_task.hpp:33
- io_env — struct, include/boost/capy/ex/io_env.hpp:44
- io_awaitable_promise_base — class, include/boost/capy/ex/io_awaitable_promise_base.hpp:86
Detail types (all in include/boost/capy/detail/io_result_combinators.hpp)
- io_result_payload — struct template, line 47 (specializations at 50 and 56)
- io_result_payload_t — alias template, line 62
- io_result_from_payload — struct template, line 85 (specializations at 88 and 97)
Outside the library (bench/example/test only)
- io_env — struct, bench/beman/sender_io_env.hpp:211
- io_sender_env — struct, example/awaitable-sender/awaitable_sender_detail.hpp:62
- io_context — class in a doc-reference test, test/doc/reference/execution_context.record.cpp:48
- Test fixtures: io_param_test, io_awaitable_promise_base_test, io_result_test, io_awaitable_test
- Doc-snippet helpers: io_step (4h_lambda_captures.cpp:36, 4g_allocators.cpp:197), io_awaitable_form (9o_why_not_tmc.cpp:57), io_awaiter_signature (4d_io_awaitable.cpp:62), io_awaitable_sketch (9k_executor.cpp:134)
IoAwaitable suggestions made:
- EnvAwaitable (Vinnie)
- ExecAwaitable (Steve)
- EnvAwareAwaitable (Andrezj)
I propose the simplification of the following type names:
capy::io_result<> -> capy::result
capy::io_env -> capy::env
For capy::io_task<...> we could just drop the alias. It would be capy::task< result<...> >
The same pattern can be applied to io_sender_env. (io_context not included, it is correct and Corosio's).
Obviously io_awaitable_base will follow whatever we can decide on for the IoAwaitable concept.
Comment your thoughts and opinions!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsDone
Activity
akrzemi1 commentedon Aug 31, 2026
I do not know why, but while I do not mind reusing popular names like
taskin namespacecapy, I feel uncomfortable withcapy::resultand it having a quite opposite meaning toboost::result.gubnik commentedon Aug 31, 2026
ExecAwaitablefeels like the most explicit name to highlight the idea of inherent executor affinity built into the protocol.EnvAwaitableandEnvAwareAwaitableare also a bit confusing in light ofstd::execution::task<T, Environment>as per P3552. If (or rather when)std:executionmodel becomes common it would be confusing to haveEnvAwareAwaitablethat isn't related tostd::executionenvironment.capy::envis fine because it is not something an unprepared user would normally encounter unless they implement an awaiitable of their own, which forces them to get acquainted with Capy's protocol anyway.I agree with Andrzej on
capy::result. It says nothing about the nature of what the user is working with, and to add insult to injury it collides withboost::resultand all the otherresultpeople write. I would prefer something more explicit, for examplecapy::partial. I am not proposing this specifically but it indicates what the user is dealing with better than justcapy::result.akrzemi1 commentedon Aug 31, 2026
IoAwaitableor its rename is also something normal people will never encouter. They will only be exposed totask<>or most of the time. Even though the docs and the papers keep using the name, user programes will not see it.Back to
result, let me share another observation. The typetuple<error_code, ...>is actually specific to an operation on a single stream. These stream operations will consume/fill a portion of the buffer, always return "what adventures happened to the stream" and often the size, which can be zero. And as long as you are operating on a single stream, you do not have to distinguish between "result from the stream" from "avoid exceptions". But the moment you do something more complicated, a simpletupleno longer serves the purpose of "avoid exceptions". For more complicated types that one would want to return, like we face now in Bost.HTTP, you now need avariant<error_code, T>. The famouspush_to/pull_fromoperations that operate on two streams suddenly need statuses of two streams to be reported.Long story short, @gubnik's
capy::partialis quite good. Other candidates:stream_result<...>.gubnik commentedon Aug 31, 2026
You are right, yes. I was thinking about a potential API outside of Capy which could use an
IoAwaitablebut that's highly unlikely now that I try to actually think of one.klemens-morgenstern commentedon Aug 31, 2026
capy::envis good.capy::io_result- I don't know why we needio_resultat all, just use atuple. I want totiemyecs.capy::task- yes, in theory we could do the same forio_awaitable.Ok, let's bikeshed
io_awaitable: maybe some obscure name is better, something that screams at you?awaitableis an alright name for a concept, in the same way thatdrivablewould make sense as a concept for my car.However, I don't think we need to strictly use nouns for concepts, this read just fine to me:
template<can_drive Car>.IoAwaitableis bad because it sounds like something that canawaitio. It's like sayingRoadDrivablebut including dirtbikes.What it actually means is: an awaitable that accepts an environment; we could either just make that implicit and go for
capy::awaitable, because that is what is awaitable in the context/environment of capy. Or we find a way to express theenvawareness - e.g.groundedAwaitable.env_awaitablesounds like it's awaiting the environment.akrzemi1 commentedon Sep 1, 2026
Looks like
EnvAwareAwaitablesatisfies your criteria.I would also like to add another name to the bikeshedding exercise. The docs use in a lot of places the term
IoAwaitable-protocol. We do not need to use the concept name (whatever name we settle on) while describing the protocol. We could use "environment-propagation-protocol".anarthal commentedon Sep 1, 2026
I like
capy::env. I don't likecapy::partialat all - that'd mean Corosio's resolver returnscapy::partial<resolver_results>. I'd consider dropping the alias.capy::resultkind conflicts withsystem::result, but if the alias is to be kept, I'd be ok with it.I'm ok with
taskdefaulting to todaysio_taskif you rename the base template tobasic_task.EnvAwaitablelooks like the most explicit to me.sgerbino commentedon Sep 1, 2026
I will just bring to your attention that it is a tuple, it is just an alias now. Maybe your suggestion is just to remove the alias?
sgerbino commentedon Sep 3, 2026
Updating this issue to the latest discussions on slack.
IoAwaitable —> ContextAwaitable
IoAwaitableRange —> ContextAwaitableRange
IoRunnable —> ContextRunnable
io_result — Remove the alias std::tuple< std::error_code, ... >
io_task — Remove the alias task< std::tuple< std::error_code, ... > >
io_env — await_context
io_awaitable_promise_base — context_awaitable_promise_base
akrzemi1 commentedon Sep 12, 2026
While at harmonizing names, I suggest that the naming around
this_corobe reconsidered. Looks like today the only usage for this namespace is to access the data previously passed viaio_env(which now may becomeawait_context). Do we envision getting other things va this mechanism (like getting direct access to the promise object)?Because these "tags" could be shorter and have names corresponding to those used when passing the context: