== Quote from BCS (a...@pathlink.com)'s article > Reply to dsimcha, > > I've been thinking a little about the idea of returning tuples from > > functions, w.r.t. Bugzilla 2628 > > (http://d.puremagic.com/issues/show_bug.cgi?id=2628). Would it be > > feasible to solve this by making struct[index] for any struct w/o an > > opIndex overload equivalent to struct.tupleof[index]? This would be > > trivial syntactic sugar, but would allow user-defined tuples in Phobos > > to look like a builtin tuple, be returned from functions, etc., while > > changing very little under the hood. Furthermore, for functions that > > take a tuple, we could allow structs to be implicitly cast to tuples, > > e.g.: > > > > struct Foo { > > uint u; > > float f; > > } > > void doStuff(uint myInt, float myFloat) {} > > > > Foo foo; > > doStuff(foo); // Implicitly casts to foo.tupleof, works. > I like the first part some (but not without reservations). As for the second > bit... I don't like it. It would make overload resolution to tricky, if not > at the compiler level than at the eyeball level.
Yeah, scratch the second part. In addition, I thought of this problem after I posted: struct Foo { uint u; float f; } void doStuff(T...)(T args) {} Foo foo; doStuff(foo); // Ambiguous. Does the struct get passed, or is it //unpacked to a tuple?