Multiple return value as requirements for safety and performance

Anonymouse via Digitalmars-d digitalmars-d at puremagic.com
Tue Dec 20 06:30:24 PST 2016


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);
> }

Nested Voldemort structs? Horcruxified, to work around the symbol 
name length explosion. I always imagined allowing for multiple 
values (in multiple fields) was part of the point behind them.

For instance, consider the several discrete pieces of data you 
get from the Result of std.regex matching. (Not all of it is via 
opIndex.)



More information about the Digitalmars-d mailing list