Functional programming

Chris Angelico rosuav at
Tue Mar 4 14:47:54 CET 2014

On Wed, Mar 5, 2014 at 12:30 AM, BartC <bc at> wrote:
> But declaring variables is not just about specifying a type; it registers
> the name too so that misspelled names can be picked up very early rather
> than at runtime (and that's if you're lucky).

The two are separate. I don't know of any language that lets you
declare a type without catching the names, but there's certainly the
other way around (ECMAScript just has "var x, y, z"). It'd be
theoretically possible to have a Python-style "variable inference"
system (if I can call it that - the rules of "if you assign to it and
don't declare it as global/nonlocal, it's local") coupled with an
optional type declaration system; if you don't declare, then it can
hold anything. I just don't know of any language that does it.

>> That convention is a bit weaker these days than it used to be. Tuples now
>> have list-like methods, and we have namedtuple for record/struct-like
>> objects with named fields.
> (Aren't tuples immutable? They wouldn't work well for records then, because
> it would be impossible to change a field of a record.)

They are, including namedtuples. But an object() can be used that way,
if you want.


More information about the Python-list mailing list