C++ traps that D2 doesn't avoid yet?
Nick Sabalausky
a at a.a
Fri Nov 7 14:48:52 PST 2008
"Derek Parnell" <derek at psych.ward> wrote in message
news:16rwvaqsxxzdx.hzsh3le743yv$.dlg at 40tude.net...
> On Thu, 6 Nov 2008 17:14:13 -0500, 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. <_<
>
> Same here. I thought the 'trap' was using %d with a *long* value.
>
In my newsgroup client, the lower-case 'L' renders as a straight vertical
line with no serif or anything else. I can't remember ever seeing a
(non-oddball) font where the "one" digit looked like that, so I
instinctively saw it as "8L" and thought the intended gotcha was a
mismatched number of bits causing a zero on a system of the wrong
endianness. That said, I do still like D's requirement that the "L" suffix
be capitalized.
More information about the Digitalmars-d
mailing list