"in" everywhere

Simen kjaeraas simen.kjaras at gmail.com
Fri Oct 8 06:58:44 PDT 2010


Juanjo Alvarez <juanjux at gmail.com> wrote:

> True! And that's the only drawback I see on generalizing "in", but there  
> are many things in programming languages that doesn't feel right when  
> you don't
> know the language well. That doesn't mean that D should be the  
> "programming for dummies on rails with a constant automated tutor  
> included" language; if I
> read well the site, it is mean to be a practical language with the  
> ability to shot yourself in the foot.

Absolutely. And one of its trademarks is being as fast as C. Now, C clearly
does not have the 'in' operator, but it is a goal in D that the obvious way
to do something should be fast and correct.


> Still, I don't understand how generalizing "in" could affect  
> std.algorithm et al if they only use "in" for AAs, just like now.

Because if 'in' is available for other uses for other containers, one would
be tempted to use it also there. The alternative is to put it in the coding
standards:

43. Thou shalt not use magic numbers.
44. Thou shalt not use 'in', as it may be slow as heck.
45. Thou shalt not write spaghetti code. Nor macaroni.

This would make the feature useless.

-- 
Simen


More information about the Digitalmars-d mailing list