First Draft: Tuple Unpacking Syntax

IchorDev zxinsworld at gmail.com
Sat Aug 23 14:07:53 UTC 2025


On Wednesday, 20 August 2025 at 16:11:42 UTC, Timon Gehr wrote:
> On 7/31/25 13:46, IchorDev wrote:
>> I really don't understand why it wouldn't be supported
>
> Because it is not implemented and there is not yet a spec for 
> it.

That's the case of the whole DIP. It sounds like they're 
proposing tuple unpacking whereby it always requires a copy; 
which would defeat some of the point of having functions return 
tuples in the future, because it'd be no better (from a code 
optimisation standpoint) than just placing the return values in a 
struct & unpacking manually.

> I guess one way to do it for tuples would be to move each field 
> on its own if the unpack rhs is an rvalue. Not sure how to 
> implement that, but I can try during the dconf hackathon. I 
> guess would need to call the move constructor and then blit 
> `.init` on the source field.
>
> Ideally though it would not even run the destructor on the 
> moved fields anymore. Eliding all the destructor calls would 
> need some cooperation from the tuple type though.

Yes. That sounds amazing. Please, please do all of that.

> I had hoped there would be some way to move on last use and 
> avoid any further destructor calls, but it's not really where 
> we have been moving so far

Alas...


More information about the dip.development mailing list