D dropped in favour of C# for PSP emulator
Ali Çehreli
acehreli at yahoo.com
Sat May 12 00:37:15 PDT 2012
On 05/12/2012 12:26 AM, SomeDude wrote:
> On Saturday, 12 May 2012 at 00:12:07 UTC, 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'.
>
> I'm not sure what you're talking about, there is no implicit conversion
> to bool.
> dmd returns:
>
> bug.d(6): Error: cannot implicitly convert expression (foo in bar) of
> type int* to bool
>
> With the cast(bool), everything works fine.
Which example are you testing with?
// With dmd 2.059, this compiles:
void main()
{
int[int] aa;
if (42 in aa) {
}
}
// But this does not compile:
bool foo()
{
int[int] aa;
return 42 in aa;
}
Ali
--
D Programming Language Tutorial: http://ddili.org/ders/d.en/index.html
More information about the Digitalmars-d
mailing list