Extend vector ops to boolean operators?
Timon Gehr
timon.gehr at gmx.ch
Wed Mar 7 01:10:46 PST 2012
On 03/06/2012 09:58 PM, H. S. Teoh wrote:
> On Tue, Mar 06, 2012 at 09:35:11PM +0100, Timon Gehr wrote:
>> On 03/06/2012 09:30 PM, H. S. Teoh wrote:
>>> It'd be really cool if I could do this:
>>>
>>> void func(int[] vector, int[] bounds) {
>>> assert(vector[]>= 0&& vector[]< bounds[]);
>>> ...
>>> }
>>>
>>> Is there any reason why we shouldn't implement this?
> [...]
>>
>> Comparing arrays already does lexical-style comparison (which makes sense).
>
> What I wanted is not lexicographic comparison, but per-element
> comparison:
>
> v[]>=0 means v[0]>0&& v[1]>0&& v[2]>0&& ...
> v[]<b[] means v[0]<b[0]&& v[1]<b[1]&& v[2]<b[2]&& ...
>
> as opposed to lexicographical:
>
> v< b means (v[0]!=b[0]) ? v[0]<b[0] :
> (v[1]!=b[1]) ? v[1]<b[1] :
> (v[2]!=b[2]) ? v[2]<b[2] :
> ...
>
>
> T
>
I know. You asked for reasons why it shouldn't be implemented. The main
reason is that it is already valid code with different semantics.
More information about the Digitalmars-d
mailing list