Avoiding local variable declarations?

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Mon Nov 17 07:32:35 EST 2008


On Mon, 17 Nov 2008 10:10:16 +0000, Jorgen Grahn wrote:

> On Thu, 13 Nov 2008 12:49:02 -0800 (PST), dpapathanasiou
> <denis.papathanasiou at gmail.com> wrote: ...
>>> but what's wrong with you original code?
>>
>> I come from a functional programming school of thought, where you avoid
>> local variable declarations if at all possible.
> 
> I'm not sure that's universal.  Using Standard ML at Uni, it was often
> useful to use "let name = expr in expr" (or whatever the syntax was) to
> simplify an expression. Directly borrowed from mathematics, I assume.

That's (also?) Haskell syntax and I agree that it is useful to write 
readable code.

> 'name' is not a variable, of course; there are no variables in
> functional programming. Can't remember what it's called -- named
> expression, maybe?

I think it's called variable and works like variables work in 
mathematics, i.e. you can assign only once.  Not such illogical crap like 
``a = a + 1`` which must be obviously false unless 1 is defined as the 
neutral element for the definition of ``+`` here.  :-)

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list