Optional extra return value? Multiple return values with auto?

Chris NS ibisbasenji at gmail.com
Tue Jul 24 05:37:37 PDT 2012


On Tuesday, 24 July 2012 at 08:56:21 UTC, David wrote:
> Am 24.07.2012 05:25, schrieb ReneSac:
>
> I whish there was:
>
> auto foo() {
>     return Tuple!("foo", "bar", 1, new Custum());
> }
>
> void main() {
>     auto (s1, s2, i, c) = foo();
> }

I think the main blocker to something like that right now is the 
compiler's ability to detect and guarantee that the returned 
tuple will always be a specific series of types (or at least 
implicitly convertible to a common series).  And in order for 
that, tuples would, I imagine, need to be a part of the language 
proper.  If I'm wrong about that last requirement, then I'm 
honestly not sure what the main obstacle to this is.

-- Chris NS


More information about the Digitalmars-d-learn mailing list