Worst ideas/features in programming languages?

Dukc ajieskola at gmail.com
Wed Dec 29 09:44:25 UTC 2021


On Wednesday, 29 December 2021 at 06:48:11 UTC, Walter Bright 
wrote:
> On 12/28/2021 9:14 PM, Walter Bright wrote:
>> Actually, I agree with the need for tuples, and am very open 
>> to a good design for it.
>
> I'd like to see something that unified arrays, structs, 
> argument lists (for functions).

I think we should unify static arrays and tuples, and call it a 
day. A tuple or a static array still would not be the same as an 
argument list, but could be easily converted to one with 
`.expand`, just like the present-day tuple.

As for `struct`s, I think it's better they're not interchangeable 
with other types by default. One reason is that we still want 
that overloads like this are possible:
```d
void setBackgroundColour(RGB colour);
void setBackgroundColour(HSV colour);
```

This way, the author of a type can decide whether the type should 
be interchangeable:
```d
// not interchangeable with other types of similar structure
struct Vector(size_t dim)
{ private float[dim] content;
   ref opIndex(size_t i){return content[i];}
}

// This would be interchangeable
alias Vector(size_t dim) = float[dim];

// Also interchangeable
alias Vector(size_t dim) = Tuple!(Repeat!(dim, float));
```

Also, If we accept https://github.com/dlang/DIPs/pull/173 (I 
definitely like it!), I suggest that we also make `void` the same 
type as `Tuple!()` and `AnyType[0]`.


More information about the Digitalmars-d mailing list