[phobos] tie for std.typecons.Tuple

Denis 2korden at gmail.com
Mon May 10 05:32:00 PDT 2010


On Mon, May 10, 2010 at 2:22 PM, Masahiro Nakagawa <repeatedly at gmail.com> wrote:
> Hi,
>
> Currently, Phobos has Tuple but doesn't have tie.
> So I implemented tie for std.typecons.Tuple.
>
> http://www.bitbucket.org/repeatedly/scrap/src/tip/tie_.d
>
> Original author is 9rnsr but his version is a bit messy and overkill.
> I substantially rewrote his tie.
> - clear syntax (tie(&n, &d) => tie(n, d))
> - Implicit conversion
>
> I would like to suggest this tie is integrated into phobos.
>
> What do you think of this?
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>

Looks great. Just 2 questions:
1) Does chaining works? I.e.
tie(a, b) = tie(c, d) = tuple(1,2); // a = b = 1, b = c = 2

2) You could probably use __dollar for ignored elements, to prevent
namespace pollution and symbol conflicts:
tie(a, $) = tuple(1, 2); // a = 1

This leads to another idea: Phobos should have struct Dolllar and
global __dollar variable so that everyone don't have to redefine it,
just import some Phobos module and use it.


More information about the phobos mailing list