JunoLab / Media.jl

Julia Display System
Other
5 stars 11 forks source link

setdisplay on Parameteric types #2

Closed rohitvarkey closed 8 years ago

rohitvarkey commented 8 years ago

I'm not sure if this is a bug or a feature. Thought I'd report it anyway.

For usual types the steps given in the documentation work fine. But when I was trying to do the same with parametric types I observed that the types needed to be specified for it to work. For example,

julia> type foo2{T}
           a::T
           b::T
       end

julia> foo2(1,2)
foo2{Int64}(1,2)

julia> setdisplay(foo2, BlinkDisplay._display)
DevTools.BlinkDisplay.WebView(Any[Blink.AtomShell.Windo....#more such output

julia> foo2(1,2) #This displays in the REPL itself
foo2{Int64}(1,2)

julia> setdisplay(foo2{Int64}, BlinkDisplay._display)
DevTools.BlinkDisplay.WebView(Any[Blink.AtomShell.Windo....#more such output

julia> foo2(1,2) #This displays in the Blink window.

Please note that I was checking with v0.1.1 and not master. Whenever I switched to master, Media was not working properly. Will file a separate issue for that.

MikeInnes commented 8 years ago

Improvements for this kind of thing definitely welcome. Perhaps as a first pass we could just always strip out the type parameters and, effectively, remove support for parametric types within Media.jl – I'm not sure how necessary they'd really be anyway. OTOH, making this work properly seems like it would require essentially reimplementing Julia's dispatch logic – unless we can reuse it somehow.

MikeInnes commented 8 years ago

So I've changed this to strip parameters from types before finding a display. That pretty much suits my usecase, but I'm open to improvements.