Extend vector ops to boolean operators?

Peter Alexander peter.alexander.au at gmail.com
Tue Mar 6 18:35:08 PST 2012


On Tuesday, 6 March 2012 at 23:57:07 UTC, James Miller wrote:
> On 7 March 2012 10:58, Kapps <opantm2+spam at gmail.com> wrote:
>> On Tuesday, 6 March 2012 at 20:28:40 UTC, 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
>>
>>
>> Would this be possible with UFCS?
>>
>> int opCmp(T)T([] array, T element) { ... }
>> int opCmp(T)(T[] array1, T[] array2) { ... }
>
> I like this idea, at least adding an opSliceCmp 
> operator-overload
> would do as a start, I think thats the correct name for it. I 
> can't be
> bothered to check.
>
> --
> James Miller

It has to be done as vector operations.

a[] < b[] should equal [a[0] < b[0], a[1] < b[1], ... ]

What the OP has asked for is not a vector operation, so it 
shouldn't use the vector op syntax.


More information about the Digitalmars-d mailing list