Is this a bug in std.typecons.Tuple.slice?
Ola Fosheim Grøstad via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Feb 9 08:33:20 PST 2016
On Tuesday, 9 February 2016 at 16:00:09 UTC, Marc Schütz wrote:
>> 2. Tuples use structural typing, not nominal typing.
>
> This has no relevance for the question at hand.
It does if you allow casting and to use tuples a types in
aggregates. The language becomes less strongly typed.
>> 3. They are identity-less. If you can take reference and
>> compare, they no longer are identity-less.
>
> Like value types in general, nothing special about tuples here.
I don't know what you mean by that. D doesn't provide proper
value types. If you can compare identities (address) then it is
not a value, but an object.
> I believe it's more because the concept is more frequently used
> in functional programming languages, for which immutability is
> not surprising. Other languages do have mutable tuples, e.g.
> Swift and C++11 (std::tuple).
C++ doesn't have real tuples. I don't know the details of Swift
regarding tuples, but Swift is an OO language that does not aim
for high performance or very strong typing.
> As said above, wanting to avoid spilling is not a reason to
> disallow spilling. Besides, fixed-size arrays seem more similar
> to SIMD registers, and they don't have the restrictions you
> tuples to have.
Well, I disagree. There is very little reason to encourage people
to use tuples for storage, you end up with a weaker typed
language and less performant code.
(You can do various types of packing in registers too, depends on
the CPU.)
More information about the Digitalmars-d-learn
mailing list