Does D have too many features?

Alex Rønne Petersen xtzgzorex at gmail.com
Sun Apr 29 13:24:05 PDT 2012


On 29-04-2012 06:36, Andrej Mitrovic wrote:
> On 4/29/12, Timon Gehr<timon.gehr at gmx.ch>  wrote:
>> - 'in' operator returning a pointer to the element.
>
> AFAIK this is a property of how the opIn_r function is implemented,
> nothing much to do with the language itself.

I hate to nitpick and all that, but opBinaryRight!"in" actually works 
now. ;)

>
> But it does allow for some neat tricks, like:
>
>      int[int] hash;
>      hash[1] = 2;
>      int value = *enforce(1 in hash, new Exception("1 not in hash"));
>      assert(value == 2);
> or:
>      if (auto val = 1 in hash)
>          ...use val pointer (+ if it's a class/struct pointer you still
> have access to the dot syntax)
>      else
>          ... errors..


-- 
- Alex


More information about the Digitalmars-d mailing list