digitalmars.D.learn - are std.traits.FieldNameTuple and std.traits.Fields returned value
- mw (5/5) Jun 20 2020 Are their returned value, i.e the field names and their types are
- Stanislav Blinov (7/12) Jun 20 2020 Yes, in the same order and of the same length. You need two
- mw (4/13) Jun 22 2020 Can we add this information to the doc? to make it clear to the
- Stanislav Blinov (7/11) Jun 22 2020 It's pretty clear in that doc already:
- mw (5/7) Jun 23 2020 Just-Did-It:
Are their returned value, i.e the field names and their types are always in the same order, and of the same length? If they are not, how to get sync-ed pairs (name, type)? If they are, why we need two separate calls, which cause confusion.
Jun 20 2020
On Saturday, 20 June 2020 at 20:17:54 UTC, mw wrote:Are their returned value, i.e the field names and their types are always in the same order, and of the same length? If they are not, how to get sync-ed pairs (name, type)? If they are, why we need two separate calls, which cause confusion.Yes, in the same order and of the same length. You need two because they're not calls (and the results are not "return values"), they're tuples constructed out of compile-time type information, and the former (FieldNameTuple) has to generate new symbols, which may not be desirable in cases when you don't need the names.
Jun 20 2020
On Saturday, 20 June 2020 at 20:42:03 UTC, Stanislav Blinov wrote:On Saturday, 20 June 2020 at 20:17:54 UTC, mw wrote:Are their returned value, i.e the field names and their types are always in the same order, and of the same length? If they are not, how to get sync-ed pairs (name, type)? If they are, why we need two separate calls, which cause confusion.Yes, in the same order and of the same length.Can we add this information to the doc? to make it clear to the user: https://dlang.org/library/std/traits.html
Jun 22 2020
On Monday, 22 June 2020 at 19:55:29 UTC, mw wrote:It's pretty clear in that doc already: alias FieldNameTuple(T) = staticMap!(NameOf,T.tupleof[0..__dollar-isNested!T]); alias Fields(T) = typeof(T.tupleof[0..__dollar-isNested!T]); But if you'd like it spelled out in text as well, you can make a PR for the Phobos repository.Yes, in the same order and of the same length.Can we add this information to the doc? to make it clear to the user: https://dlang.org/library/std/traits.html
Jun 22 2020
On Monday, 22 June 2020 at 20:08:37 UTC, Stanislav Blinov wrote:But if you'd like it spelled out in text as well, you can make a PR for the Phobos repository.Just-Did-It: https://github.com/dlang/phobos/pull/7540 The point of doc is that the user don't have to dive into the code to know it's usage.
Jun 23 2020