Closed Jules-Bertholet closed 1 year ago
I'm not sure where to put this, but rather than
for<T, U in Ts, Us>
I would find either of
for<(T, U) in Ts * Us> // Borrowed from scalar vector multiplication, definitely strange too though.
or
for<(T, U) in Zipped<Ts, Us>> // where `Zipped<...>` is a built-in variadic utility type accepting
// only tuples of tuples with the same arity as its parameter list.
more intuitively readable, as
for<T, U>
already stands for the Cartesian product of the comma-separated types.
Either would also match the syntax in for
-loop expressions well in terms of symbol precedence.
@Tamschi
I would appreciate further discussion of my specific proposal on the Internals thread, or directly on the HackMD for smaller comments.
There are two big reasons why the design of for<... in ...>
is the way it is:
Zipped<Ts, Us>
should be implementable in user code.for<'a, T, const N: usize in 'as, Ts, Ns>
.Is there a summary of what's different from the previous note? With the file rename it's unclear to me what the additions are here.
The rename is its own commit, so if you review commit-by-commit you should be able to see the diff.
syntax bikeshedding:
rather than static for
use type for
since it's kinda a type-level for loop since it iterates over the field types.
@programmerjake Please direct comments/bikeshed on my proposal specifically to the Internals thread, or directly on the HackMD for minor suggestions, so I can have it all in one place to review. (Addressing your type for
suggestion: while I am not overly fond of static for
, I would note that it designed to allow looping over values, lifetimes, types, and consts. type for type T in Ts
would seem to me to be particularly awkward).
Adds: