On Mon, Feb 17, 2014 at 2:04 PM, Jameson Nash <[email protected]> wrote:
> I would expect that it could resolve it, not that the code inference
> for that has necessarily been written. In your first example, it is
> not provable (without additional assumptions) that the global
> represented by f will not change, and thus Vector{Any} is the best
> possible result.
>
Hmm.. not sure how f could be changed - what additional assumptions might
there be? Would have thought it just as const as a:
function f(i); i; end
(which does work fine)
If you care about the type of the result, then use a typed
> comprehension: `Int[f(x) for x in [1,2,3]]`. A generalized
> comprehension is (by definition) allowed to return any array type it
> wants (but typically tries to pick something fast).
>
The problem with typed comprehension is there may be conversions you're not
aware of. I preferred to leave this out to avoid that (no automatic
conversion and all that). Sounds like I need to do this though..
> This
> [(function(x) x; end)(x) for x in [1,2,3]]
> seems like a very complicated way of writing
> this
> [x for x in 1:3]
>
or [1:3]
Yes the point was just to look at the embedding of the function in the
statement, in contrast to a lambda, not to say it would actually be used :)