On Friday, May 11, 2012 16:47:44 Ali Çehreli wrote: > On 05/11/2012 02:45 PM, Timon Gehr wrote: > > On 05/11/2012 10:10 PM, Nick Sabalausky wrote: > >> I use 'in' all the time, and I never even think about it returning a > >> pointer. I just do: > >> > >> if(foo in bar) > >> > >> And it just works. So I don't see a particularly big problem here. > > > > Try this: > > > > bool fun(){ return foo in bar; } > > Isn't that an inconsistency in the language then? Are pointer values > implicitly convertible to bool or not?
No. They're not. Very little in D is implicitly convertable to bool. Conditions in if statements and loops are special. if(cond) {} gets translated to if(cast(bool)cond) {} So, in the case of in inside an if condition, you get if(cast(bool)(foo in bar)) {} - Jonathan M Davis