On Sun, 10 Feb 2008 20:31:55 +0100, Alf P. Steinbach wrote:
> * Leon -> Alf P. Steinbach:
>>
>>
>> You think casts are useless?
>
> No, they're in the language for a reason.
>
> That reason is not to make code that one does not understand, compile.
>
>
>> Then I want you to read some integers from a fstream, since fstream's
>> read method returns chars only.
>
> stream >> myInt;
>
> Of course it may be that you're talking about binary i/o, since you
> mention read().
>
> In that case, consider whether binary i/o really is what you need. Most
> often it's not.
>
>
>> In some cases
>> you are right, and is a cast stupid.
>
> Most often, a cast is stupid. But the reason for that isn't that casts
> are inherently bad. The reason is that they're so often abused.
>
>
>> But maybe it works for this case.
>
> When it "works" technically it's even worse than when it clearly
> doesn't, because it can then give a false impression of doing something
> right, and so easy too... Leading to much worse problems down the road.
>
>
>> And if i say something wrong, please explain me my mistake,
>
> Already done.
>
> Simply don't recommend casts as solutions. They're generally not. If
> one wants less type checking then the appropriate solution is to use a
> language with even less strict type checking, and/or not defining types.
>
>
>> and don't
>> respond so unkind. Or do you want to say you never make mistakes?
>
> I would want to say that, yes. :-) Unfortunately, the road to
> perfection is longer than my estimated lifetime. But who wouldn't want
> to live that long?
>
>
> Cheers, & hth.,
>
> - Alf
Okay, thank you for the info. I will remember it :)
Grz, Leon