On Mon, 10 May 2010 21:32:00 +0900, Denis <[email protected]> wrote:

On Mon, May 10, 2010 at 2:22 PM, Masahiro Nakagawa <[email protected]> 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?


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

http://www.bitbucket.org/repeatedly/scrap/changeset/e4c270e6c30d
Done.

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

I don't understand this. Please show me example.
I tried following code with dmd 2.046 beta:
-----
import std.stdio;

struct Dollar {}
__gshared Dollar __dollar;

void main()
{
    writeln($);
}

// foo.d(8): '$' is valid only inside [] of index or slice
-----
Umm...

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.

I agree.
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos

Reply via email to