What is Expressiveness in a Computer Language

George Neuner gneuner2/ at comcast.net
Tue Jun 27 11:42:07 EDT 2006


On Mon, 26 Jun 2006 13:02:33 -0600, Chris Smith <cdsmith at twu.net>
wrote:

>George Neuner <gneuner2/@comcast.net> wrote:
>
>> I worked in signal and image processing for many years and those are
>> places where narrowing conversions are used all the time - in the form
>> of floating point calculations reduced to integer to value samples or
>> pixels, or to value or index lookup tables.  Often the same
>> calculation needs to be done for several different purposes.
>
>These are value conversions, not type conversions.  Basically, when you 
>convert a floating point number to an integer, you are not simply 
>promising the compiler something about the type; you are actually asking 
>the compiler to convert one value to another -- i.e., see to it that 
>whatever this is now, it /becomes/ an integer by the time we're done.  
>This also results in a type conversion, but you've just converted the 
>value to the appropriate form.  There is a narrowing value conversion, 
>but the type conversion is perfectly safe.

We're talking at cross purposes.  I'm questioning whether a strong
type system can be completely static as some people here seem to
think.  I maintain that it is simply not possible to make compile time
guarantees about *all* runtime behavior and that, in particular,
narrowing conversions will _always_ require runtime checking.


>> I can know that my conversion of floating point to integer is going to
>> produce a value within a certain range ... but, in general, the
>> compiler can't determine what that range will be.
>
>If you mean "my compiler can't", then this is probably the case.  If you 
>mean "no possible compiler could", then I'm not sure this is really very 
>likely at all.

Again, the discussion is about narrowing the result.  It doesn't
matter how much the compiler knows about the ranges.  When the
computation mixes types, the range of the result can only widen as the
compiler determines the types involved.

George
--
for email reply remove "/" from address



More information about the Python-list mailing list