Discussion Thread: DIP 1037--Add Unary Operator ...--Community Review Round 1

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Mon Nov 2 06:29:45 UTC 2020


On Monday, 2 November 2020 at 03:49:41 UTC, Manu wrote:
> On Mon, Nov 2, 2020 at 8:15 AM Ola Fosheim Grøstad via 
> Digitalmars-d < digitalmars-d at puremagic.com> wrote:
>> Well, it is a good thing if they behave as immutable structs 
>> as you then can get a more uniform language.
>
> I think it is conceptually improper for a tuple to have a 
> memory layout; especially considering tuples can hold elements 
> that are types or aliases in addition to typed values.

D should reduce the number of types you have to account for in 
generic code.

> It's also extremely complicated to know what the output of 
> `...` applied to
> an array-like thing should be? Is it a tuple? If you apply 
> `...` to an
> array or a range, and it becomes a tuple, that is probably 
> going to reveal
> serious semantic problems.

It should not be a tuple, it should be an extension of a comma 
list. Think splat operator.

The compiler only needs to know the length of the sequence in 
order to expand.

>   fun(constantRange); // <-- function receives range as argument
>   fun(expr(constantRange)...); // <-- the function call fails

I dont understand this example.

>
> Or this:
>   immutable int[] allTheThings = [ ... ];
>   alias Selection = AliasSeq!(5, 1, 15);
>   alias res = allTheThings[Selection]...; // <-- we have an 
> array, and a
> tuple both participating in the map; if `...` applied to 
> array-like-things,
> then this extremely important pattern would be impossible

I suggested explicit indexing, so not a problem.





More information about the Digitalmars-d mailing list