Under what circumstances should I expect Mathematica to turn a delayed assignment into an immediate assignment? I have put together a minimal example (available here) which demonstrates this behavior. There is a package which contains basically the following, where each line has its own cell in the notebook from which the package is generated:

setMyVar[a] := (var = 1;)
setMyVar[b] := (var = 2;)
setMyVar[c] := (var = 3;)
setMyVar[d] := (var = 4;)
setMyVar[e] := (var = 5;)
setMyVar[f] := (var = 6;)
setMyVar[g] := (var = 7;)
setMyVar[h] := (var = 8;)
setMyVar[i] := (var = 9;)
setMyVar[j] := (var = 10;)
setMyVar[k] := (var = 11;)
setMyVar[l] := (var = 12;)
setMyVar[m] := (var = 13;)
setMyVar[n] := (var = 14;)
setMyVar[o] := (var = 15;)
setMyVar[p] := (var = 16;)
setMyVar[q] := (var = 17;)
setMyVar[r] := (var = 18;)
setMyVar[s] := (var = 19;)
setMyVar[t] := (var = 20;)

When I load this package and then evaluate Definition[setMyVar] every assignment is defined as a Set rather than a SetDelayed in Mathematica However if I comment out any three of these, everything returns to being SetDelayed. Does anyone have any idea why Mathematica would do this? If so, is there a system variable I can change to address this problem? The tarball also contains a notebook which demonstrates the behavior in a setting which is not loaded from a package.

This does not come up if everything is in a single cell, but arranging everything in such a way is not practical for the actual application in which I ran across this. To address why this might be considered to be a problem, I ran across this while using DistributeDefinitions["Context"] which as stated in the documentation essentially runs ParallelEvaluate on every statement in the context, and this is causing things to be evaluated which should not be.

Edit to add: I have confirmed that this occurs with Mathematica as well. Both machines tested are Linux x86-64.

  • 2
    $\begingroup$ I confirm this behavior in Mathematica 8.0.4. Undocumented Language`ExtendedDefinition and Language`ExtendedFullDefinition show the same as Defintion. $\endgroup$ May 23, 2014 at 17:02
  • $\begingroup$ The question is then whether or not this is an intended behavior, to which I would wager "no." If there is a consensus on that, can this be marked as a bug? I will pass it along to Wolfram, reporting back on whatever I get as a response. $\endgroup$ May 23, 2014 at 17:30
  • 2
    $\begingroup$ I just have checked this in Mathematica 5.2 and behavior is the same. Looks like a bug to me due to inconsistency with the parallel processing functionality. If you wish to mark it as a bug please include in the question some code demonstrating wrong behavior of DistributeDefinitions. It will be interesting to hear the responce from WRI on this issue. $\endgroup$ May 23, 2014 at 19:24

1 Answer 1


If you test the code above, i.e. run


it works correctly (i.e. var is set to 20).

The problem is actually one of "Definition" rather than SetDelayed. Definition is a weird function that simply prints some info to the screen. In this case, it gets it wrong, i.e. there is a bug in Definition. As a work around, if you want authoritative information on a symbol, use


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.