unsigned policy (implicit conversions for complex?)

James Dennett jdennett at acm.org
Mon Feb 12 19:43:15 PST 2007


Walter Bright wrote:
> Derek Parnell wrote:
>> On Mon, 12 Feb 2007 16:03:14 -0800, Andrei Alexandrescu (See Website For
>> Email) wrote:
>>
>>> http://erdani.org/d-implicit-conversions.pdf
>>  
>>> Did I forget something?
>>
>> Characters are not numbers. 
> 
> That's an enticing point of view, and it sounds good. But Pascal has
> that view, and my experience with it is it's one of the reasons Pascal
> sucks.
> 
> Examples:
> 
> 1) converting text <=> integers
> 2) converting case
> 3) doing compression/encryption code
> 4) using characters as indices (isspace() for example)
> 
> Take away the implicit conversions, and such code gets littered with
> ugly casts.

I don't find that; for reasons we don't need to go into
(except to say that I'm glad C++09 will have better Unicode
support than C++03), I've been using a separate type for
characters in a significant body of C++ code, and find very
little need for casts.  Certainly not enough to dispense
with the advantages of type safety.  When the code gets
low level enough to need integral values, I don't mind
doing the conversion manually as there will typically be
a need to handle byte ordering issues or similar too.  But
that's just in the cases I've seen in the last {mumble}
years.

The examples you give are real, make up a tiny fraction
of code that handles characters, and aren't, in my experience,
significantly adversely affected by the elimination of
these implicit conversions.

-- James



More information about the Digitalmars-d mailing list