The main thing we should try is to at least have them share as much of the 
implementation as possible, so that user defined arrays just have to 
implement one of them correctly and fast(which is non trivial, so it 
shouldn't really be done 2 times).

I propose something like this:
```

lazy_reshape(x::Scalar, shape) = ScalarRepeat(x, shape)
lazy_reshape{N}(x::AbstractVector, shape::NTuple{N, Int}) = Grid{N}(x, 
shape)
#...
function broadcast(F, x...)
    # broadcast should be about shape only
    shape = broadcast_shape(x)
    map_args = map(arg -> lazy_reshape(arg, shape), x)
    map(F, map_args...) # map should infer return types
end
```
This should be very fast and still memory efficient, as long as the 
compiler inlines nicely and infers constants correctly.


Am Samstag, 21. Mai 2016 15:26:21 UTC+2 schrieb Steven G. Johnson:
>
> It seems at first glance like broadcast(f, args...) could be interpreted 
> as a strict generalization of map(f, args...), in which case you might as 
> well just have one function (map).
>
> In particular, are there any cases where both broadcast(f, args...) and 
> map(f, args...) are applicable (sans exceptions), but the two functions 
> (intentionally) give different results?
>

Reply via email to