DIP32: Uniform tuple syntax

Yota via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 14 10:00:56 PDT 2014


On Wednesday, 13 August 2014 at 23:26:29 UTC, Dicebot wrote:
> On Wednesday, 13 August 2014 at 23:02:44 UTC, Philip Stuckey 
> wrote:
>> I'm not sure if this is off topic or redundant but couldn't 
>> many of these things be added to the standard library without 
>> a special syntax. for instance s function like unpack could 
>> allow
>>
>>    import std.typecons;
>>    int a;
>>    char b ;
>>    unpack(a,b) = tuple(5, 'A');
>>    assert(a==5 && b=='A');
>>
>> instead 0f
>>
>>    (int a, char b) = (5,'A');
>>
>> or whatever.
>>
>> Would this help the problem?
>
> This is already possible with standard library but the fact 
> that declarations need to be separate makes people not happy.

Brings to mind C#'s new ability to declare locals within 'out' 
arguments.
if (int.TryParse("123", out int i)) { ...use 'i'... }


More information about the Digitalmars-d mailing list