Basically because the size of Float64 is known, Float64[] is stored
compactly in memory and allows the use of optimized mathematical routines.
A Real Array can hold any type of real simultaneously (Float64, Float32,
BigFloat), and therefore is stored as an array of pointers.

The general way to define behaviors which work with all Real arrays is to
parametrize functions based on Array element type:

function myfunc{T<:Real}(x::Array{T})
   # ... do something fancy
end

See the following manual sections for more details:

http://docs.julialang.org/en/latest/manual/types/#man-parametric-types
http://docs.julialang.org/en/latest/manual/methods/#parametric-methods

Cheers!

   Kevin

On Tue, Jan 21, 2014 at 4:17 PM, Patrick Foley <[email protected]
> wrote:

> Is there a way to get around this?  I have a lot of types (foo1, foo2,
> ....) all of which are subtypes of an abstract (bar).  I want to be able to
> define the behavior for arrays of any of the foos just by defining the
> behavior of an array of 'bar's.  Any advice?
>

Reply via email to