Re: Visibility of value of variable bindings in module

*To*: mathgroup at smc.vnet.net*Subject*: [mg121232] Re: Visibility of value of variable bindings in module*From*: Bill Rowe <readnews at sbcglobal.net>*Date*: Mon, 5 Sep 2011 07:07:03 -0400 (EDT)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com

On 9/4/11 at 6:05 PM, cawright.99 at gmail.com (caw) wrote: >Module[{x = Sum[i, {i, Length[{1, 2, 3}]}], y = x + 1}, Print[y]; >Print[x]] >prints out: >1 + x >6 >So, in the variable declaration section of the Module statement, the >binding of x to 6 isn't visible to y. (It's a bit like let and let*, >but not) >Is there a form which will allow the bindings to be visible within >the variable declaration section? Not using Module. But clearly you could do Module[{x = Sum[i, {i, Length[{1, 2, 3}]}], y}, y = x + 1; Print[y]; Print[x]] 7 6 Or you could use Block instead of Module Block[{x = Sum[i, {i, Length[{1, 2, 3}]}], y = x + 1}, Print[y]; Print[x]] 7 6