What is Expressiveness in a Computer Language

Rob Thorpe robert.thorpe at antenova.com
Wed Jun 21 11:59:26 EDT 2006


Matthias Blume wrote:
> "Rob Thorpe" <robert.thorpe at antenova.com> writes:
>
> >> >> > No it doesn't. Casting reinterprets a value of one type as a value of
> >> >> > another type.
> >> >> > There is a difference.  If I cast an unsigned integer 2000000000 to a
> >> >> > signed integer in C on the machine I'm using then the result I will get
> >> >> > will not make any sense.
> >> >>
> >> >> Which result are you getting?  What does it mean to "make sense"?
> >> >
> >> > Well the right one actually, bad example.
> >> >
> >> > But, if I cast an unsigned int 2500000000 to signed I get -1794967296.
> >>
> >> So, why do you think this "does not make sense"?
> >
> > Well, it makes sense in terms of the C spec certainly.
> > It does not make sense in that it does not emit an error.
>
> Why not?

Well it's really a matter of perspective isn't it.  In some cases it
may even be what the programmer intends.

>From my perspective I don't expect a large positive number to turn into
a negative one just because I've requested that it be signed.  The
behaviour I would expect is that either the variable being set gets the
right number, or an error occurs.  I don't care if the reporting is at
runtime or compile time, so long as it can be seen.

--
Anyway, this is a small point.  Does the fact that you only disagreed
with me on this point indicate that you agreed with everything else?

... Only joking :) I think you and I have irreconcilable views on this
subject.
I think we can agree that value mostly have some sort of type in a
statically typed language.  You may say that they have directly have
types, but I can't see how that can be, as far as I can see they have
types only indirectly.  This is only a minor point though.

The issue of typing of values vs variables is not practically
meaningless though.

The main problem I find with statically typed programs is that much of
the world outside the program is not statically typed.  Library and API
writers in-particular seem to treat static typing carelessly.  As a
result it's not generally possible to write a program meaningfully
inside the static type system, as the type systems designers intended.
You're force to break it all over the place with casts etc anyway.  And
at every place you break it the possibility of error occurs and flow
from that place into the rest of the program.  So, you end up actually
checking the values of variables rather than relying on their types
anyway.  And this can be difficult because their values have no
associated information telling you their types.

It's different writing a function deep inside a large program, in this
case data can be cleaned up beforehand.  And in this case the static
typing works are intended and becomes more useful.


Anyway, I don't think it would help either of us to continue this
sub-thread any more.  Feel free to reply to this post, but I might not
reply back.

Static typing is rather off topic on most of the newsgroups this thread
is in anyway, and I suspect the people in them are getting rather sick
of it.




More information about the Python-list mailing list