Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 1
    $\begingroup$ To create simple functions in a more traditional way, with simple assignment (Set), use Function. $\endgroup$ Commented Dec 12, 2018 at 22:09
  • 5
    $\begingroup$ There is no "problem" to fix. You might consider truly understanding the symbolic nature of Mathematica's execution model. Once you do, a lot of these mysteries will become clear. It is unhelpful to have the execution model of a "traditional" language like C or Python in mind while programming in Wolfram Language. $\endgroup$ Commented Dec 12, 2018 at 22:09
  • 1
    $\begingroup$ The scoping seems like it should be a separate issue from delayed assignment. Suppose I have a computationally-intensive calculation that I want done once; that is a perfect candidate for =, especially if I am going to NIntegrate or ContourPlot3D it later. But if I have a formula that will only need to be calculated in a few cases, that is a perfect candidate for :=. And those are separate questions from whether the parameters should be locally scoped. $\endgroup$ Commented Dec 13, 2018 at 0:21
  • 1
    $\begingroup$ Can anyone give me an example of how the behavior I described is ever beneficial? $\endgroup$ Commented Dec 13, 2018 at 0:22
  • 2
    $\begingroup$ It is beneficial when the right-hand side is to derive a big exprssion, for example, then it does not have to derive it every time when called. Please, as @Shredderroy mentioned above, keep the symbolic capabilities of Mathematica in mind. $\endgroup$ Commented Dec 13, 2018 at 1:46