Thanks for clarifying that!
So do you suggest
[code]
function foo(x::bar)
  #the function body
end

function foo(x::AbstractVector{bar})
  map(foo, x)
end
[/code]

On Thu, Feb 11, 2016 at 10:33 AM, Tim Holy <tim.h...@gmail.com> wrote:

> If the input is a scalar and the output is a scalar, that's also
> type-stable.
> Type-stability is about "predictability of the output type, given the input
> types," not "always returns the same type."
>
> Also, wrapping scalars in an array will have a significant performance
> cost.
>
> Best,
> --Tim
>
> On Thursday, February 11, 2016 12:44:19 AM Michael Borregaard wrote:
> > Note that both of these versions will return an array, allowing for type
> > stability
> >
> > Den torsdag den 11. februar 2016 kl. 09.40.27 UTC+1 skrev Michael
> >
> > Borregaard:
> > > If you are worried about maintaining two versions, that can be solved
> > > simply:
> > > function foo(x::Vector{bar})
> > >
> > >   #the main code of your function
> > >
> > > end
> > >
> > > function foo(x::bar)
> > >
> > >   foo([x])
> > >
> > > end
>
>

Reply via email to