# What's with the weird HoldRest Attribute of ParallelMap?

Bug introduced in 10.0 or earlier and persisting through 11.1

I have noticed some odd behavior of ParallelMap: When the list, that is mapped over, is not inserted explicitly (but rather in the form of some other command, like Range[...]), there are some cases, where I get unexpected results. For example, when I run

ParallelMap[f,Range[Range[4]]]


I get

{f[1], f[2], f[3], f[4]}

{f[{1}], f[{1, 2}], f[{1, 2, 3}], f[{1, 2, 3, 4}]}

which is what I get, when I run

ParallelMap[f,Evaluate[Range[Range[4]]]]


If I do the same thing with Map instead of ParallelMap, I do get the expected result. Now, I realize, that this is ultimately because ParallelMap has the attribute HoldRest, but this is in stark contrast to the Documentation stating

ParallelMap will give the same results as Map, except for side effects during the computation.

Is this a bug, or some intended behavior I just don't understand (and the Documentation fails to convey)? If this is a Bug, then why would ParallelMap have the attribute HoldRest in the first place? Neither the levelspec parameter, not the Method or DistributedContexts options seem to justify this. Also, some lists are evaluated before they are mapped over (e.g. ParallelMap[f,Range[4]] gives the same result as Map and as ParallelMap[f,Evaluate[Range[4]]]). Any ideas?

• I would report this to Wolfram support. Can you do that please? – Szabolcs Aug 8 '17 at 10:57
• I looked a little bit at the sources of ParallelMap (found in Combine.m). It reduces to ParallelCombine, which treats certain seconds arguments such as Range, Table, FileNames, etc. in a special way. Why? I didn't take the time to figure it out, but I assume it may be an attempt at optimization. This is where things go wrong. If we define range=Range, and use range (to prevent ParallelCombine from using the special-case implementation), then the problem goes away. – Szabolcs Aug 8 '17 at 11:17
• I am going ahead and tagging this as a bug, but please do report it to Wolfram. – Szabolcs Aug 8 '17 at 11:19
• I just reported it to Wolfram. – Subject625 Aug 8 '17 at 12:07
• I see this bug in Mathematica 8.0.4 as well. – innaiz Aug 8 '17 at 14:22