On Sat, Apr 02 2016, Yichao Yu wrote:

> On Sat, Apr 2, 2016 at 8:35 AM, Tamas Papp <[email protected]> wrote:
>> On Sat, Apr 02 2016, Yichao Yu wrote:
>>
>>> On Sat, Apr 2, 2016 at 2:28 AM, Tamas Papp <[email protected]> wrote:
>>>> On Fri, Apr 01 2016, Yichao Yu wrote:
>>>>
>>>>> On Fri, Apr 1, 2016 at 5:33 AM, Tamas Papp <[email protected]> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I ran into a problem with the result type of Dict comprehensions. If I
>>>>>> wrap the comprehension in a function, it produces the narrowest type,
>>>>>> otherwise the type of value is Any. Code looks like this:
>>>>>
>>>>> https://github.com/JuliaLang/julia/issues/7258
>>>>
>>>> Sorry, I don't understand why it is the same issue. The type of
>>>> arguments in the comprehension is always the same, just that one version
>>>> is wrapped in a function inside a function, and the other one isn't.
>>>
>>> And that's exactly where type inference sensitivity comes in. One of
>>> them is inferable and the other not.
>>
>> Thanks, now I think I get it. So for the time being, is wrapping
>> something in a function to make it inferable a reasonable general
>> workaround?
>>
>
> Depend on what you need. If it works than sure.
> Supplying the type manually also works, if you can easily determine it
> of course.

Rereading #7258 I convinced myself that I should supply the type
manually. Two questions:

1. Is Dict{keytype,valuetype}([...my comprehension...]) the preferred
syntax, that will survive to 0.5?

2. If I am computing the type of A/B and I know that their types are
TypeA and TypeB, what's the preferred way of computing the result type?
I came up with

typeof(one(TypeA)/one(TypeB))

but maybe there is something more elegant.

Best,

Tamas

Reply via email to