ParallelDo is having problems evaluate an expression that evaluates fine outside ParallelDo. The problem is not due to the use of functions with side effects because I managed to trace the problem to the following very simple parallelizable task.

If I define the following function that takes arguments with a certain Head (the last Head before symbol to be precise, see Taking Head of function in operator form (and manipulating arguments in operator form)).


This works fine in ParallelDo, however if I define


and the function


then tstToString2 works fine outside ParallelDo, but not within it. In ParallelDo it will always leave tstToString2[bla[stuff][stuff]] unevaluated. For example:

ParallelDo[Print[tstToString[bla[{f, pe, 0}][1][1, 0]]<>"b"],{vv,0,0}]

will give an error for StringJoin since the first expression will still not be a string.

How do I reliably write code that works the same in ParallelDo, when something as simple as this can screw it up. Are there some general practices that I am missing?

(The point is not to find a work around here, but to find some guiding principles for what screws things up. Otherwise I am afraid I cannot reliably work with ``.)

The answer might be version dependent because it occurs for 11.1.1 for Linux x86 that is used on a cluster I use but not on my own machine running 11.3.0 for Linux x86.

  • 1
    $\begingroup$ DistributeDefinitions ? $\endgroup$
    – ktm
    Jun 18, 2019 at 18:42
  • 1
    $\begingroup$ @user6014, but why specifically would i have to distribtute this definition by hand and not others. What is the logic behind that? It seems completely random. All functions are defined in the same way (same context) as far as I can tell. So I either expect them all to automatically be distributed or none of them. $\endgroup$
    – Kvothe
    Jun 19, 2019 at 8:23

1 Answer 1


I believe that this is due to a bug that existed prior to version 11.3.0. In later versions ParellelDo behaves as expected.


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.