I want to create my own Tuple type
Paul Backus
snarwin at gmail.com
Mon Jan 11 20:52:25 UTC 2021
On Monday, 11 January 2021 at 20:36:30 UTC, Ola Fosheim Grøstad
wrote:
> On Monday, 11 January 2021 at 19:25:06 UTC, Paul Backus wrote:
>> I agree that immutability has benefits, but I don't see why
>> tuples should be singled out for special treatment in this
>> regard.
>
> Oh, and another reason is that scalars can usually be passed by
> value with impunity, but you might want to pass tuples by
> reference as it could save you some copying in a significant
> way. And pass by reference would make the tuple vulnerable to
> mutation... (since we don't have head-const).
All of what you're saying applies equally well to any struct type
as it does to tuples.
It sounds like what you really want is for D *in general* to have
head-const, for all types. So there's no reason to force it on
tuples in particular. Just write your DIP for 'readonly', and if
it's accepted, you can write `readonly(Tuple)` and get the result
you want for free.
More information about the Digitalmars-d-learn
mailing list