D dropped in favour of C# for PSP emulator
Jonathan M Davis
jmdavisProg at gmx.com
Fri May 11 22:48:22 PDT 2012
On Friday, May 11, 2012 22:41:08 Ali Çehreli wrote:
> On 05/11/2012 05:12 PM, Timon Gehr wrote:
> > On 05/12/2012 01:47 AM, 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?
> >>
> >> Ali
> >
> > if(condition) { ... }
> >
> > is equivalent to
> >
> > if(cast(bool)condition) { ... }
> >
> > i.e. this conversion is 'explicit'.
>
> WAT. That's an "implicit explicit" conversion, which I have never known
> existed! :p
It nicely solves the issue of wanting to be able to easily check conditions
which aren't strictly booleans without having to cast to bool (as is _very_
common to do in C++) while avoiding all of the pitfalls that implicit
conversions give you everywhere else. So, it _is_ a bit confusing without a
full explanation, but it's definitely a solid solution as far as usability goes
IMHO.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list