I dun a DIP, possibly the best DIP ever

Walter Bright newshound2 at digitalmars.com
Fri Apr 24 20:34:53 UTC 2020


On 4/24/2020 5:55 AM, Nick Treleaven wrote:
> On Friday, 24 April 2020 at 08:04:29 UTC, Walter Bright wrote:
>> On 4/24/2020 1:03 AM, Walter Bright wrote:
>>> On 4/24/2020 12:10 AM, Manu wrote:
>>>>    alias Tup = AliasSeq!(0, 2, 3);
>>>>    void fun(int);
>>>>    fun(Tup);  // scalar argument receives tuple, it can expand, so: fun(0), 
>>>> fun(1), fun(2)
>>>
>>> Write it as:
>>>
>>>      Tup.fun();
>>
>> Incidentally, belay that. That will currently produce: fun(0, 2, 3);
> 
> This syntax is an unfortunate inconsistency with your proposal, but how often is 
> variadic UFCS used ATM? Its existence has been pointed out in a NG reply before 
> (I think by Timon), but it seemed to surprise people. Perhaps it could be 
> deprecated - use fun(Tup) instead. The latter is more intuitive as people tend 
> to think UFCS is for the first argument, not multiple arguments.

Whether it's intuitive or not depends on your point of view. For example, if you 
view a tuple as members of a struct, the current behavior makes perfect sense. 
(I've actually wanted to make a tuple equivalent to a struct, but the darned 
function call ABI got in the way.)


>> Of course,
>>
>>     fun(1, Tup);
>>
>> cannot be rewritten in this way
> 
> AliasSeq!(1, Tup).fun(); // fun(1); fun(0); fun(2); fun(3);

Are you sure? It does fun(1, 0, 2, 3) when I try it.


More information about the Digitalmars-d mailing list