between and among: worth Phobosization?

Byron byron.heads at gmail.com
Tue Dec 17 10:55:42 PST 2013


On Tuesday, 17 December 2013 at 18:15:29 UTC, Andrei Alexandrescu 
wrote:
> On 12/17/13 8:43 AM, Byron wrote:
>> I don't know why we can do this instead:
>>
>> if(foo in ["alpha", "beta", "delta"] ) {
>>
>> }
>
> It's a good idea.
>
>> basically have an opIn operator  x in y -> y.opIn(x)
>> U* opIn(T, U)(T key)
>> can define in runtime for arrays, and allow custom ones to be 
>> defines
>
> No, that should only work for literal arrays.

Any major reason why? Right now in reminds of + operator in java, 
only language devs can decide how its used.

>
>> and
>>
>> if(1 < x <= 10) {
>>
>> }
>>
>> I remember this being shot down before...
>
> "Don't change semantics of C code".

How does this change semantics of C code anymore then in, is, ~ 
does? Its okay if this has been beaten to death and you don't 
want to comment more on it.

>
>> Both of these are easier to read, and are more natural.  They 
>> also cover
>> more cases.
>
> No - "among" could take a custom predicate.

Is that not just a special case of reduce/filter/find then?

>
>
> Andrei




More information about the Digitalmars-d mailing list