C++ traps that D2 doesn't avoid yet?

Don nospam at nospam.com
Fri Nov 7 00:17:52 PST 2008


Walter Bright wrote:
> Jarrett Billingsley wrote:
>> On Thu, Nov 6, 2008 at 5:07 PM, Walter Bright
>> <newshound1 at digitalmars.com> wrote:
>>> BCS wrote:
>>>> Reply to Walter,
>>>>
>>>>> Steven Schveighoffer wrote:
>>>>>
>>>>>> Even experienced developers fall into some of these traps.  I know I
>>>>>> occasionally fell into this trap:
>>>>>>
>>>>>> if(x);
>>>>>> x->doSomething();
>>>>>> But no more with D, because it's not allowed.  Those kinds of things
>>>>>> can be easily prevented, and are common mistakes by all programmers.
>>>>>>
>>>>> Here's another fun one:
>>>>>
>>>>> printf("%d\n", 8l);
>>>>>
>>>>> What does that print?
>>>>>
>>>> 8
>>> If I hadn't said it was a trap, I bet you'd have said "81".
>>
>> I wouldn't've, because I use a font that actually distinguishes things
>> 1, I, l, and | properly.  <_<
> 
> 0 and O is another fun one. In any case, 8l is legal C, but illegal D.

In CompSci1 we had use some ridiculous Mac editor where 0 and O were 
100% identical, I,l, | and 1 also. It was an incredible source of bugs.
We had to write a parser/emulator for some stupid imaginary asm language 
they'd invented, where O01 was output register 1. Plus, whitespace was 
significant, but it wasn't a monospaced font...
It was like the whitespace programming language.



More information about the Digitalmars-d mailing list