What is Expressiveness in a Computer Language

Rob Thorpe robert.thorpe at antenova.com
Tue Jun 20 19:20:33 CEST 2006


Darren New wrote:
> Rob Thorpe wrote:
> > The compiler
> > relys entirely on the types of the variables to know how to correctly
> > operate on the values.  The values themselves have no type information
> > associated with them.
>
> int x = (int) (20.5 / 3);
>
> What machine code operations does the "/" there invoke? Integer
> division, or floating point division? How did the variables involved in
> the expression affect that?

In that case it knew because it could see at compile time.  In general
though it doesn't.
If I divide x / y it only knows which to use because of types declared
for x and y.

> >>Casting in C takes values of one type to values of another type.
>
> > No it doesn't. Casting reinterprets a value of one type as a value of
> > another type.
>
> No it doesn't.
> int x = (int) 20.5;
> There's no point at which bits from the floating point representation
> appear in the variable x.
>
> int * x = (int *) 0;
> There's nothing that indicates all the bits of "x" are zero, and indeed
> in some hardware configurations they aren't.

I suppose some are conversions and some reinterpretations.  What I
should have said it that there are cases where cast reinterprets.




More information about the Python-list mailing list