Multiple return value as requirements for safety and performance

Ilya Yaroshenko via Digitalmars-d digitalmars-d at puremagic.com
Tue Dec 20 06:08:08 PST 2016


On Tuesday, 20 December 2016 at 14:04:26 UTC, Nicholas Wilson 
wrote:
> On Tuesday, 20 December 2016 at 13:47:50 UTC, Ilya Yaroshenko 
> wrote:
>> One good thing for safety and CTFE is allow multiple return 
>> value. In combination with `auto ref` it is _very_ powerful:
>>
>> ----
>> auto ref front()
>> {
>>   // Returns 2 values, each value is returned by reference if 
>> possible
>>   return (a.front, b.front);
>> }
>> ----
>>
>> Mir libs will use pointers for now. This is one of reasons why 
>> `zip` is slow.
>> The new feature also significantly extends std.range and 
>> std.algorithm functionality.
>>
>> This thread was forked from
>> http://forum.dlang.org/post/acdwfbirvoxzrsfyltqd@forum.dlang.org
>>
>> I am not good in DIPs and hope someone is interested in this 
>> feature too
>
> Do tuples work for this?

No, tuples stores either value or pointer. If it stores pointer 
then it is not safe and it is not CTFE.


More information about the Digitalmars-d mailing list