I have run into an interesting situation using a compiled function with VectorPlot (and StreamPlot) to plot 2D slices of a 3D vector field, wherein I get the following error:

CompiledFunction::cfsa: Argument x at position 1 should be a machine-size real number. >>

but the operation still produces the desired results.

Consider a function ff (simplified for the example's sake)

ff[{x_, y_, z_}] := {x, y, z}

ffcomp = Compile[{{x, _Real}, {y, _Real}, {z, _Real}}, ff[{x, y, z}]]

Plot3D:

Plot3D[ff[{x, 0, y}][[{1, 3}]], {x, 0, 2}, {y, 0, 2}]

Plot3D[ffcomp[x, 0, y][[{1, 3}]], {x, 0, 2}, {y, 0, 2}]

produce identical results with no error messages.

VectorPlot (or StreamPlot)

VectorPlot[ff[{x, 0, y}][[{1, 3}]], {x, 0, 2}, {y, 0, 2}]

VectorPlot[ffcomp[x, 0, y][[{1, 3}]], {x, 0, 2}, {y, 0, 2}]

Produce the same results but the second case gives the error message shown above. What is the difference in how VectorPlot and Plot3D treat their arguments that causes this?

BTW, working from a suggestion I found on stackexchange, if I define the function

ff2[x_?NumericQ, y_?NumericQ, z_?NumericQ] := ffcomp[x, y, z]

VectorPlot[ff2[x, 0, y][[{1, 3}]], {x, 0, 2}, {y, 0, 2}]

no error message is produced.

So, in summary, while I can get Mathematica to do what I need it to, I'm still trying to fully understand how the world of Hold/Release/Evaluate work.