All components of x will have the same (random) value. Now suppose I do instead:

x = zeros(10)
x .= rand.()

Since rand.() is dotted, I’d expect it to apply to each element of x separatedly. In this case, I should obtain ten distinct random values. However the result is the same as above (a single random value fills the whole vector).

Even though rand.() has no arguments, it still should “apply to each element separatedly”. At least that’s what my intuition tells me.

Actually it seems @Tamas_Papp approach makes more sense.

The .= means do the operation in broadcasting way.
Now, broadcasting is operation which its input is array (Or arrays).
It shouldn’t be driven by rand() function.

Seems useful to have it but no coherent as a language.

@RoyiAvital This is fine if you do x .= rand(). However, the point is that if you use a dot in rand.() (as in x .= rand.()), it should be broadcasted too.

x .= rand() is equivalent to broadcast!(identity, x, rand()), so rand is called only once.

x .= rand.() is equivalent to broadcast!(rand, x). So (in 0.6), rand() is called once for each element of x.

The nice thing about the latter is that you can do vectorized operations with random numbers without requiring a temporary array to fill with rand(n) or rand! first. For example, x .+= y .* rand.() occurs entirely in-place in a single loop, adding a random fraction of each element of y to each element of x. (Or equivalently, you can do @. x += y * rand() in 0.6, allowing you to omit all of the dots.)

Just to be clear, I was not making a normative statement, just describing how I think 0.5.0 works. I think the broadcasting semantics of 0.6 are very nice, including the example above by @stevengj and also the broadcasting on Nullables; I am looking forward to both (and the inevitable corner cases which will be surprising ).