-
Notifications
You must be signed in to change notification settings - Fork 65
Rework getproperty
for LObjects to be inferrable for fields
#507
Conversation
Now I'm noticing that there are quite a few other such |
Why does my previous code not infer correctly? I thought that the symbols used in |
Because Here's how you can see the problem for yourself (obviously, don't use this PR, use master or a released version): julia> using AbstractPlotting, Cthulhu
julia> using AbstractPlotting.MakieLayout
julia> scene, layout = layoutscene();
julia> ax = LAxis(scene);
julia> f(axis) = axis.scene
f (generic function with 1 method)
julia> @descend f(ax) If you don't know how to use Cthulhu, I can't recommend it highly enough. It's hard to imagine a better use of half an hour. This video is about invalidations but starting at 7:00ish it's basically a Cthulhu tutorial. |
In case it's not apparent, the implication is that almost nothing in Makie is inferrable, even the fields that you've gone to the effort to put concrete types on. |
Oh, and I missed the second part of your question because I was focused on the first. Yes, https://github.com/JuliaPlots/AbstractPlotting.jl/blob/master/src/dictlike.jl#L80-L96 fixes the problem too---that's basically what I meant above by a |
So perhaps you can just delete the specialized |
I do think if you delete the specialized methods then given https://github.com/JuliaPlots/AbstractPlotting.jl/blob/master/src/dictlike.jl#L80-L96 you're probably OK, so there may be no reason to merge this. |
thank you, I think I'll look at just applying the existing definitions to my MakieLayout types. I was simply not aware of this mechanism at the time so I duplicated existing structure (and in an inferior way..) |
This addresses one of the points in MakieOrg/Makie.jl#706. If
ax
is anLAxis
, thenax.scene
should infer concretely (it refers to a field) whereasax.ylabel
(an attribute) will not.Demo: here's the function body for
LAxis
:This is therefore quite similar to https://timholy.github.io/SnoopCompile.jl/stable/snoopr/#Inferrable-field-access-for-abstract-types-1.