Small Vectors Proposal
Mikola Lysenko
mclysenk at mtu.edu
Tue Jan 30 12:34:22 PST 2007
Frits van Bommel wrote:
> Mikola Lysenko wrote:
>> All new vector types are pass-by-value, and may be used in combination
>> with any number of other types. The following expressions would all
>> be valid:
>>
> [snip 2 others]
>> char[][ucent4] c;
>
> [snip]
>
>> Note that the only two comparison operators allowed on vectors are ==
>> and !=. The problem with <, >, etc. is that there is no commonly
>> agreed upon definition for such things. Therefore the operators are
>> omitted to avoid confusion.
>>
>> int2(1, 2) == int2(1, 2); //ok, evaluates to true
>> float3(1, 0, 0) < float3(0, 0, 1); // error, < is undefined for
>> vectors
>
> These two sections are contradictory: associative arrays need an
> ordering to be defined on the key type.
> How about a simple lexicographical order, with two non-equal vectors (of
> the same dimensionality) comparing as their first non-equal component
> would? (That's how comparisons work for arrays IIRC)
>
>
> Other than that I don't see any obvious problems with it.
Hmm... Fair enough. We could define ordering on a per component level
arbitrarily so associative arrays work. I could see this being
confusing in some situations, but it would be worth it in order to make
the types consistent. Therefore:
float3(x, y, z) < float3(a, b, c)
would translate too:
(x < a) ? true : ((y < b) ? true : (z < c))
More information about the Digitalmars-d
mailing list