On Tue, 24 Jul 2012 13:00:44 +0200, Jonathan M Davis <jmdavisp...@gmx.com> wrote:

On Tuesday, July 24, 2012 11:03:16 Simen Kjaeraas wrote:
On Tue, 24 Jul 2012 04:21:18 +0200, Andrei Alexandrescu

<seewebsiteforem...@erdani.org> wrote:
>> Tuple!(float, "x", float, "y") bar() {
>> return typeof(return)( 0.0, 0.0 );
>> }

[snip]

> We could make
>
> return tuple(0.0, 0.0);
>
> to work. I can't imagine a scenario in which this relaxation would cause
> a bug.

I would argue it should work, for the exact reasons outline above. And as
you say, it should cause no bugs.

But can it be made to work in current D, as a library solution? Or do you mean the language should be changed? (This looks to me a lot like the old
opImplicitCast)

That's what alias this is for.

Well, sorta. See, I'm asking for an unbounded set of possible
conversions, as Tuple!int should be implicitly convertible to
Tuple!(int, "a"), Tuple!(int, "b"), Tuple!(int, "Help"), and
Tuple!(int, "AnotherOneBitesTheDust").

And that's just the ones with int as the first parameter. Then comes
float, double, long, and so on.

I may be wrong, but I don't think alias this can handle that. In fact,
I just tried, and got DMD to hang.

--
Simen

Reply via email to