Private Properties in Julia 0.7


Julia 0.7 supports method propertynames(x, private=false)
The latest documentation for that method reads

‘‘propertynames(x) may return only “public” property names that are part of the documented interface of x. If you want it to also return “private” fieldnames intended for internal use, pass true for the optional second argument. REPL tab completion on x. shows only the private=false properties.’’

Does Julia 0.7 let you define a property/field as readonly when you define a (mutable) struct,
or is the overloaded method propertyname responsible for enforcing private=true?

How does the REPL know when a property is private?

Also, how are methods getproperty, and setproperty expected to deal with private properties?



This has no influence on running code, it is purely for documentation and things like tab completion.


OK, I take it that the property related methods will have to enforce private=true if desired.
But how does “tab completion” (i.e. the REPL) know that a property is supposed to be private?


It only looks at the propertynames(x, private=false). It’s up to x to return the appropriate thing. Right now, the default definition for a struct will return all its fields.