Tuple DIP

Martin Nowak code+news.digitalmars at dawg.eu
Fri Feb 16 19:51:40 UTC 2018


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 01/12/2018 11:44 PM, Timon Gehr wrote:
> As promised [1], I have started setting up a DIP to improve tuple 
> ergonomics in D:
> 
> https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md

Pardon me if things have been said already, can't really read through
all the thread.

- - Regarding underscore as placeholder.

https://issues.dlang.org/show_bug.cgi?id=13522

- - Regarding the "limitation"

Maybe you want some auto-packing feature there? Doesn't seem too bad,
we could come up with sth. when this turns out to become a common
nuisance.
Have you considered to lower (1, 2, 3)[0 .. 2] to tuple(tuple(1, 2,
3)[0 .. 2]) or using a non-std.typecons tuple where slicing does not
expand?

- - closed tuples?

The reference to std.typecons.tuple implies contiguous struct memory
layout (closed tuples).
This is a bit subtle for unpacking assignments which lower to

AliasSeq!(x, y) = tuple(y, x)[];

so on the left-hand side of an assignment, the syntax refers to a
non-contiguous (open) tuple.

Declarations like

auto (a, b) = (1, 2);

also seem to declare an open tuple (non-contiguous memory).

I assume that unpacking function arguments behaves similarly, i.e. on
ABI level, each argument is passed separately.


Overall looks really good. I think that would make for a great
addition to the language.

- -Martin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEpzRNrTw0HqEtE8TmsnOBFhK7GTkFAlqHNkgACgkQsnOBFhK7
GTka+A/9HVHrawW5XyqzpGnT+qkyaG3a4dZdVvHbs9gJ0x7SHDyBgjKs576dW7g5
GEfGFjPkEZqKGvbtWgSicRV01qNmyGfVsgmWestK59niQAHLMUYx8PBsmeX/1CP9
MxLPMx9a0Z+h0D1z8sCLjHV5NcVZLziP3lnuUUvVXLUEv/gBZV52Eu++/iJmqKaj
K9Boyv2+IrTTkv426PNxCy1iblMVi7B2bP44HErwij9+si8Zby3O8ExAh97MOBdH
eoPT6TzmJxpExUfdiXcJ26HFxa4V8WhB/YaS50uYoUUYbaj0njtLwLyCkzUsjGzb
JV32ZI7ncfHmMHCaJ09SGHfvh2dHKHa/VHU5ar3ivnzAXBLjdoe7MNi3QGH+zi6M
U+RtY6WBkiVnYcLmanmMJKhyRsj3k3qT1I4zmVm6kbrs/oBqegtQcFoiQxm/DNMc
LKLlNTEWuWIFquA6rd5OJ7kxhdbv5dE9vAgDNYcPP8GOB78sbZMQKxBTcI0a1EQC
JYYvICiI9+CqjIeOU0F/LDv48JIk5BGSrh8m0cjwUtq4ivGEKo4V6Oc+1smsXmAo
+XpSyyQi/t8pj037w0zSS0KA88qL4Fc4fvuujNnr5a9AkiV7zrMb9oyM00+F7cgo
UApw3Lpr9g8GBKKu8HcbzGQMq86TYq/unSsD3ZFJEA3PCz8/5aY=
=VB2T
-----END PGP SIGNATURE-----


More information about the Digitalmars-d mailing list