Extend vector ops to boolean operators?

Simen Kjærås simen.kjaras at gmail.com
Tue Mar 6 13:10:16 PST 2012


On Tue, 06 Mar 2012 21:35:11 +0100, Timon Gehr <timon.gehr at gmx.ch> 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?
>>
>>
>> T
>>
>
> Comparing arrays already does lexical-style comparison (which makes  
> sense).

Comparing two arrays makes sense, absolutely. Comparing one T[] and
one T currently does not. Also, foo[] already changes the behavior of
operators on foo, making it do a per-element compare would be in line
with this pattern.

This is also already in bugzilla:
http://d.puremagic.com/issues/show_bug.cgi?id=5636


More information about the Digitalmars-d mailing list