Python Strings

Jonadab the Unsightly One jonadab at bright.net
Tue Sep 19 07:43:17 EDT 2000


Darren New <dnew at san.rr.com> wrote:

> C is statically typed and weakly typed. Smalltalk is dynamically strongly
> typed. There are dynamically weakly-typed languages (FORTH, perhaps?) and
> static strongly-typed languages (Pascal, say).
> 
> Static/dynamic refers to whether variables have types checked by the
> compiler. Strong/weak refers to how easy it is to circumvent the type of
> values, i.e., do inappropriate things with the bitpatterns. I'm not sure how
> the normal terminology applies to type inference systems, but I'm pretty
> sure it's at least strongly typed; I'm not sure if it's considered dynamic
> or static or something else.
> 
> Once one straightens this out, the confusion tends to go away.

Hmmm...  so I suppose it's the dynamic typing I really like in
Inform and Perl, though they are weakly typed as well, which
doesn't bother me.  Or something like that.

Actually, this discussion has me trying to classify Inform's
typing system, and I'm having trouble.  Perhaps if I describe
its typing system you can tell me how to classify it...

Everything is an integer.  I'll explain.  If you assign an
integer to a variable, that integer is literally stored in
the variable itself -- so the variable actually holds the
integer.  If you assign anything *else* to a variable,
the item itself is not stored.  An integer is stored.  For
some kinds of things (strings, routines) the stored value
is a packed address.  For other kinds of things (attributes,
properties, dictionary words, objects, classes, ...) the 
value stored is a unique ordinal number.  (So, the first
dictionary word that appears in the code will be 1, and
so on.  The first property declared will also be 1.  And
the first object.  Et cetera.)

So, if you have an object...

Object foo "foo";

And you give the object some attributes...

give foo openable open container;

You can copy those attributes to another object...

for (i=1:i<=last_attribute:i++) 
   if (foo has i) give bar i; 
      else give bar ~i;

Obviously that's not static typing, nor is it
strong typing.  But is it weak, dynamic typing?
It's very different from the type system of, 
say, Perl...  maybe it's yet some other kind
of typing?  Or are "weak typing" and "dynamic
typing" sufficiently general terms to include
this system?

- jonadab



More information about the Python-list mailing list