www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - returning and receiving multiple values from a function

reply timepp <tongjunhui live.cn> writes:
Now C++ allow this in a very clean way:

 std::tuple<int, bool, float> foo() {   return {128, true, 
 1.5f}; }
 auto [value1, value2, value3] = foo();
Would D plan to support that in syntax level?
May 14 2018
parent reply arturg <var.spool.mail700 gmail.com> writes:
On Tuesday, 15 May 2018 at 01:40:50 UTC, timepp wrote:
 Now C++ allow this in a very clean way:

 std::tuple<int, bool, float> foo() {   return {128, true, 
 1.5f}; }
 auto [value1, value2, value3] = foo();
Would D plan to support that in syntax level?
it depends if some dip like https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md is accepted.
May 14 2018
parent timepp <tongjunhui live.cn> writes:
On Tuesday, 15 May 2018 at 02:01:38 UTC, arturg wrote:
 On Tuesday, 15 May 2018 at 01:40:50 UTC, timepp wrote:
 Now C++ allow this in a very clean way:

 std::tuple<int, bool, float> foo() {   return {128, true, 
 1.5f}; }
 auto [value1, value2, value3] = foo();
Would D plan to support that in syntax level?
it depends if some dip like https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md is accepted.
thanks arturg ! hope this can be done sooner
May 14 2018