TypeFunction example creatiing a conversion matrix
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Fri Oct 2 02:21:03 UTC 2020
On 10/1/20 7:10 PM, Paul Backus wrote:
> 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;
> }
Interesting - this is akin to D's relaxed purity whereby a pure function
can mutate its arguments. I'm trying to wrap my head around it, e.g. is
Args considered a private copy of the argument much like a static array
passed by value?
> 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
I don't get the interaction. How does mutating the argument affect order
of declaration?
More information about the Digitalmars-d
mailing list