strong/weak typing and pointers

Mike Meyer mwm at mired.org
Wed Nov 3 08:59:33 EST 2004


Steven Bethard <steven.bethard at gmail.com> writes:

> Mike Meyer <mwm <at> mired.org> writes:
>> First of all, let's mention a truly weakly-typed language. BCPL, one
>> of C's predecessors. Variables don't have types, they just hold
>> words.
> So BCPL had no compile time checking?  If this is true, BCPL is a good example
> of a dynamically- and weakly-typed (PL theory definition) language...

I wouldn't call BCPL dynamically typed. BCPL has no run-time type
checking either. That seems to be the defining feature of dynamically
typed languages.

>> Finally, I don't see that there's that much difference between the two
>> different definitions of 'weakly typed'.  Both can be described as
>> treating an object as if it were of some type other than what it
>> really is. In one case, you abuse the raw bits, and in the other you
>> coerce the object to a different type.
> Would you then classify BCPL as weakly- or strongly-typed?  It seems like you
> might call it "strongly-typed" since every variable just holds words, so every
> use of a variable is thus just the use of a word, thus you would never be
> "treating an object as if it were of some type other than what it really is".

A word is just a unit of storage, not a type. Words hold values with
types - integer, float, pointer, code, chars. Nothing in BCPL prevents
you from treating a word as any type at all. You can call a pointer to
string, or do an integer add of a pair of floats. So it's weakly
typed.

        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list