Funny Behavior of Module

*To*: mathgroup at smc.vnet.net*Subject*: [mg124734] Funny Behavior of Module*From*: Louis Talman <talmanl at gmail.com>*Date*: Fri, 3 Feb 2012 02:09:31 -0500 (EST)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com

I know that Module exhibits some funny behavior, but this behavior is something I've never seen before. It seems wrong to me. In a new kernel session enter f[x_] := Module[{a},a = x^2; x = y; a] f[z] z Mathematica returns y for z, as it ought to. (In fact, the purpose of the code was to demonstrate to students what can happen when a Module monkeys with its formal parameters.) But f[z] returns y^2. It seems to me that it should return z^2, but that for some reason it's interpreting the first Set instruction in the body of the Module as a SetDelayed instruction. (We get exactly the same behavior if we replace that Set with SetDelayed in the code.) Can anyone explain what's going on here? ITABOAF? --Lou Talman Department of Mathematical & Computer Sciences Metropolitan State College of Denver <http://rowdy.mscd.edu/%7Etalmanl>