Postfix string literal alternative suggestion

Don Clugston dac at nospam.com.au
Tue Feb 12 04:54:24 PST 2008


bearophile wrote:
> Derek Parnell:
>> It is annoying that that sometimes 'cast' means convert and sometimes it
>> means pretend and sometimes it means something else.
> 
> I agree. I think the many casts you can find in C++ aren't much easy to use & remember,
 > but the alternative may have many disadvantages too. I think this situation 
has to be improved
 > (probably splitting the semantics to different syntaxes).

C++ hasn't got the distinction right either. Even reinterpret_cast<> sometimes 
does conversion rather than 'pretend'.

Sometimes it makes a difference to generated code.

double x = float.min*float.epsilon;

x/=3.0;

float y = 3.0f * pretendcast(float)x;
float z = 3.0f * conversioncast(float)x;

-->
y is float.min*float.epsilon
z is 0.

For DMD, cast(float) is a pretend cast, not a conversion cast.
But a conversion cast also makes sense, and could be useful.








> 
> Bye,
> bearophile



More information about the Digitalmars-d mailing list