Why would Mathematica break normal scoping rules in Module?
Posted
by Davorak
on Stack Overflow
See other posts from Stack Overflow
or by Davorak
Published on 2010-04-29T18:03:40Z
Indexed on
2010/04/29
18:07 UTC
Read the original article
Hit count: 128
programming-languages
|mathematica
As was pointed out in a recent post scoping does not work as expected inside of Module.
An example from that thread is:
Module[{expr},
expr = 2 z;
f[z_] = expr;
f[7]]
(*2 z$1776*)
But the following works as almost as expected.
Module[{expr},
expr = 2 z;
Set@@{f[z_], expr};
f[7]]
(*14*)
What language design consideration made wolfram choose this functionality?
© Stack Overflow or respective owner