Examples of `getproperty`, `setproperty!`, ... usage

Can someone suggest packages to check for examples of the use of getproperty, setproperty!, etc.? I currently have functions named getθ, setθ!, … in the MixedModels package. The θ vector is a property of the model but not a field in the LinearMixedModel struct. It needs to be assembled from other pieces when extracting and to be spread over those pieces when setting a new value. This seems to be a natural usage of the getproperty, … scheme but I want to make sure I don’t miss subtleties when implementing it.

Having written the question, I suppose that the LinearAlgebra package is a good place to start. Other suggestions?


I don’t think there are any subtleties. Maybe only that you probably also want to implement propertynames (for auto-completion) and the soon to come hasproperty.

1 Like

Heavily WIP and subject to change, and not claiming to be “correct”, but this code forwards anything it cannot find in the object to a “parent”.

I had the same issue, trouble getting this working. Got a working answer here Help with `Base.getproperty` syntax.

1 Like