[Issue 2779] alias this + tuple expansion on function call doesn't work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 22 09:53:21 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=2779



--- Comment #7 from Kenji Hara <k.hara.pg at gmail.com> 2011-07-22 09:53:16 PDT ---
I understand your argue. You want to distinguish one argument and many
arguments explicitly.

But... it is inconsistent to me.

My patch also support tuple expanding on initializer, foreach aggregator, and
foreach range front.

On Initializer:
----
TypeTuple!(int, double) f = tuple(10, 2.2);
assert(f[0] == 10);
assert(f[1] == 2.2);
----
Sample is (int, double) vs Tuple!(int, double).
It is similar to  void func(int, double) vs tup (typed as Tuple!(int, double)).
If we allow automatically expansion on initializer, it will be obscure why not
allow expansion on function arguments.
Or, we should write like follows?
----
TypeTuple!(int, double) f = tuple(10, 2.2).expand;
----

On Foreach aggregator:
----
auto tup = tuple(10, 2.2, "str");
foreach (e; tup)
{
    static if(is(typeof(e)==int)) assert(e == 10);
    static if(is(typeof(e)==double)) assert(e == 2.2);
    static if(is(typeof(e)==string)) assert(e == "str");
}
----
We can write tup.expand instead of tup. This is in line with your claim.

On Foreach range front:
----
auto r = zip(sequence!"n"(), "hello world")
foreach (i, c; r)
{
   if (i == 0) assert(c == 'h');
   if (i == 1) assert(c == 'e');
   ...
}
----
According to your claim, we should write r.front.expand, but it can't.
In this case, automatically expansion is NEED.
Is automatically expansion support depending on locaiton?


Totally, disallowing auto-expansion only on function arguments is inconsistent
to me.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list