D dropped in favour of C# for PSP emulator

Jonathan M Davis jmdavisProg at gmx.com
Fri May 11 14:57:51 PDT 2012


On Friday, May 11, 2012 23:45:30 Timon Gehr wrote:
> On 05/11/2012 10:10 PM, Nick Sabalausky wrote:
> > "Mehrdad"<wfunction at hotmail.com> wrote in message
> > news:oksltzwvkdrrjidcnqnm at forum.dlang.org...
> > 
> >> On Friday, 11 May 2012 at 18:16:02 UTC, Alex Rønne Petersen wrote:
> >>> On 11-05-2012 20:05, Mehrdad wrote:
> >>>> 6. The 'in' operator returns a pointer (instead of a boolean). Which is
> >>>> fine, except that it's not what you'd expect in any languages other
> >>>> than
> >>>> C/C++. i.e. Non-intuitive
> >>> 
> >>> I've always found it very intuitive actually... and it saves me from
> >>> having to write extra code to do the actual lookup (speed isn't even the
> >>> point here, I just want concise code).
> >> 
> >> Yes, I agree, but consider that D users should NOT have to work with
> >> pointers to do something so basic, like testing to see if something is in
> >> an associative array!
> >> 
> >> The mere fact that it uses a pointer makes it unintuitive to a large
> >> number of people coming from C#/Java/Python/etc.
> > 
> > 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; }

Then you do

bool fun() { return cast(bool)(foo in bar); }

It's not a big deal at all. It's just that if you expect in to return bool 
rather than a pointer, you're going to be surprised at what happens when you 
write a function like that rather than use it in an if condition. But since 
the documentation clearly states that it returns a pointer, it shouldn't 
really surprise anyone - unless they failed to read either the documentation 
or TDPL and go completely off of what they _think_ the code should mean without 
actually reading anything which would teach them the language (which is a bad 
idea anyway).

- Jonathan M Davis


More information about the Digitalmars-d mailing list