PEP 3107 and stronger typing (note: probably a newbie question)
steve at holdenweb.com
Thu Jul 5 14:36:52 CEST 2007
Paul Rubin wrote:
> John Nagle <nagle at animats.com> writes:
>> This has been tried. Original K&R C had non-enforced static typing.
>> All "struct" pointers were equivalent. It wasn't pretty.
>> It takes strict programmer discipline to make non-enforced static
>> typing work. I've seen it work in an aerospace company, but the Python
>> crowd probably doesn't want that level of engineering discipline.
> I think even enforced static types wouldn't cure what I see as the
> looseness in Python. There is not enough composability of small
> snippets of code. For example, the "for" statement clobbers its index
> variable and then leaks it to the outside of the loop. That may be
> more of a culprit than dynamic types. Perl and C++ both fix this with
> syntax like
> for (my $i in ...) ... (perl) or
> for (int i = 0; i < n; i++) ... (C++, Java)
> making a temporary scope for the index variable. Python even leaks
> the index variable of list comprehensions (I've mostly stopped using
> them because of this), though that's a recognized wart and is due to
> be fixed.
Wow, you really take non-pollution of the namespace seriously. I agree
it's a wart, but it's one I have happily worked around since day one.
> Python would be helped a lot by some way to introduce temporary
> scopes. We had some discussion of this recently, concluding that
> there should be a compiler warning message if a variable in a
> temporary scope shadows one from a surrounding scope.
Yeah, well the approach to scoping could really be improved, but if you
keep your namespaces small it's not difficult to keep things straight. I
have always been rather guarded in my approach to accessing non-local
scopes because the coupling is rather less than obvious, and is subject
to variation due to non-local changes.
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
More information about the Python-list