Yes, you do need the .primary to make a maker.  My mistake, I did not 
notice the last part of your question.

julia> immutable Foo{D}
        x::D
       end
julia> onefoo=Foo(1)
Foo{Int64}(1)

julia> thePartYouWant(x) = typeof(x).name
thePartYouWant (generic function with 1 method)

julia> this = thePartYouWant(onefoo); this, typeof(this)
Foo, TypeName



 

On Tuesday, January 5, 2016 at 4:29:06 AM UTC-5, Sheehan Olver wrote:
>
> Thanks! you do need the .primary:
>
> *julia> **typeof(f).name(4.0)*
>
> *ERROR: MethodError: `call` has no method matching call(::TypeName, 
> ::Float64)*
>
> Closest candidates are:
>
>   BoundsError()
>
>   BoundsError(*::Any...*)
>
>   DivideError()
>
>   ...
>
>
>
> *julia> **typeof(f).name.primary(4.0)*
>
> *Foo{Float64}(4.0)*
>
>
>
> On Monday, January 4, 2016 at 11:30:17 AM UTC, Jeffrey Sarnoff wrote:
>>
>> I meant: typeof(f).name
>>
>>
>> On Monday, January 4, 2016 at 6:27:43 AM UTC-5, Jeffrey Sarnoff wrote:
>>>
>>> try Foo.name (without the '.primary'), and as Mauro says (try not to use 
>>> it much)
>>>
>>>
>>> On Monday, January 4, 2016 at 5:39:53 AM UTC-5, Mauro wrote:
>>>>
>>>> This should do the trick: 
>>>>
>>>> Foo.name.primary 
>>>>
>>>> (I think this defeats type inference, so try not to use it in 
>>>> performance critical code) 
>>>>
>>>> On Mon, 2016-01-04 at 11:31, Sheehan Olver <[email protected]> wrote: 
>>>> > If I have a type 
>>>> > 
>>>> > ```julia 
>>>> > immutable Foo{D} 
>>>> >  x::D 
>>>> > end 
>>>> > 
>>>> > f=Foo(5) 
>>>> > ``` 
>>>> > 
>>>> > 
>>>> > then `typeof(f)` gives me `Foo{Int}`.  Is it possible to get access 
>>>> to just 
>>>> > `Foo`?  I.e., I want to do: 
>>>> > 
>>>> > ``` 
>>>> >     F=droptemplates(typeof(f))  # returns pointer to Foo 
>>>> >     F(1.0) 
>>>> > ``` 
>>>>
>>>

Reply via email to