Multiple return value as requirements for safety and performance

Ilya Yaroshenko via Digitalmars-d digitalmars-d at puremagic.com
Tue Dec 20 07:42:52 PST 2016


On Tuesday, 20 December 2016 at 15:36:27 UTC, jmh530 wrote:
> On Tuesday, 20 December 2016 at 14:56:37 UTC, Ilya Yaroshenko 
> wrote:
>
>>
>> As you can see the output should be 1000, but it is 1.
>>
>
>
> I was a little confused by what you meant, but the following 
> main is a little more obvious to me
>
> void main()
> {
> 	auto c = front();
> 	c[0] = 1000;
> 	import std.stdio;
> 	writeln(c[0]); //prints 1000
> 	writeln(a[0]); //prints 1
> }

c is value. You can modify it with tuples. Tuples can be returned.

This thread is about mutiple values returned by _reference_. 
Tuples can not do it, only pointers, but they are not ctfeable 
and safe


More information about the Digitalmars-d mailing list