You could also write permutedims(["foo", "bar"]) if you already had the vector.
Note BTW that the reason this can’t work is that Julia doesn’t have non-standard evaluation. The function histogram has no way of seeing what variable names were used, all it gets (in this case) is a vector of vectors of numbers, after everything inside its () has been worked out.
It seems to be consistent with line plots, where each column of a 2d array is a series. So it would make sense for each label to be a column. From the documentation:
x = 1:10; y = rand(10, 2) # 2 columns means two lines
plot(x, y, title = "Two Lines", label = ["Line 1" "Line 2"], lw = 3)
Histograms get converted into x-y data under the hood, making it non-obvious what the labels correspond to. But we can guess each resulting column is still a series, so the labels work in columns as well.