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

Mike Parker aldacron at gmail.com
Fri Nov 7 07:38:22 PST 2008


Lars Kyllingstad wrote:
> Bill Baxter wrote:
>> On Fri, Nov 7, 2008 at 7:37 AM, Walter Bright
>> <newshound1 at digitalmars.com> 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.
>>
>> Threre are various good programmer fonts out there today that are
>> designed to make the 1 l | and 0 O distinctions clear.
>> I use the Proggy fonts.  
>> http://www.proggyfonts.com/index.php?menu=download
>>
>> These days I'd say if you're not using one of these fonts for
>> programming you're being an extremely silly person.
>>
>> --bb
> 
> I use and recommend the DejaVu Sans Mono font. With this font there is 
> no chance of confusing those troublesome characters, and it's very easy 
> on the eyes. Also, the DejaVu fonts are available in the repositories of 
> many (most?) Linux distributions.
> 
>    http://dejavu.sourceforge.net/
> 
> -Lars

I was surprised to learn I already have several versions of Deja Vu 
installed (on Windows). I've configured all of my text editors and even 
Thunderbird to use it now. What a difference! Thanks for pointing it out.



More information about the Digitalmars-d mailing list