TypeFunction example creatiing a conversion matrix
Paul Backus
snarwin at gmail.com
Thu Oct 1 23:10:36 UTC 2020
On Thursday, 1 October 2020 at 21:34:50 UTC, Adam D. Ruppe wrote:
>
> So some facility to turn a ctfe array back into a tuple - the
> dereifiy step basically - with compiler assistance I think will
> be practical.
What if we could just mutate tuples locally?
template staticMap(alias F, Args...) {
static foreach(ref Arg; Args)
Arg = F!Arg;
alias staticMap = Args;
}
The obvious objection is "the spec says order of declarations
doesn't matter", but this is a case where the spec is just
flat-out wrong (see previous discussion of "compile-time race
conditions" [1]). So, given that declaration order is in fact
significant in D, we may as well officially acknowledge it and
reap the benefits.
[1]
https://forum.dlang.org/thread/swbmgrhtoiqtqokmqniu@forum.dlang.org?page=2#post-rccfbm:24sjv:241:40digitalmars.com
More information about the Digitalmars-d
mailing list