Tuples a first class feature, manu's new unary operator and named arguments

Timon Gehr timon.gehr at gmx.ch
Sat May 9 14:28:37 UTC 2020


On 09.05.20 15:19, Mark wrote:
> On Friday, 8 May 2020 at 22:20:03 UTC, Timon Gehr wrote:
>> On 08.05.20 22:38, 12345swordy wrote:
>>> As I am working on the "Tuples first class feature" dip (will 
>>> uploaded first draft soon), I noticed that if we would allow this in D:
>>>
>>> fun((int x = 10, int y = 1, int z = 2)...);
>>>
>>> Could this be used as a replacement for named arguments?
>>
>> No, too ugly. Anyway, there should not be a difference in features for 
>> tuples and multiple function arguments. In mathematics, those are the 
>> same thing. (I.e. each function has one parameter, which may be a 
>> tuple.) Ideally, built-in tuples and multiple function arguments 
>> should interact in a way that is consistent with this principle.
> 
> In mathematics you don't have function overloading. I believe this could 
> cause ambiguities if tuple parameters are automatically "unpacked".

You can easily have function overloading and fully sane tuple semantics 
at the same time. It is true that in D, some compromises might have to 
be made in order to preserve backwards compatibility. I think my attempt 
[1] [2] does that quite well, but maybe there is an even better way.



[1] https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md 
(Proposal 2)
[2] https://github.com/dlang/dmd/compare/master...tgehr:tuple-syntax


More information about the Digitalmars-d mailing list