I noticed that one can overload getproperty with String, not only Symbol (PyCall does this):
julia> struct Foo end
julia> import Base: getproperty
julia> getproperty(::Foo, x::Symbol) = x
getproperty (generic function with 22 methods)
julia> getproperty(::Foo, x::String) = x
getproperty (generic function with 23 methods)
julia> Foo().sdf
:sdf
julia> Foo()."sdf"
"sdf"
But it doesn’t work with, e.g., integers (this is even a parse error):
julia> getproperty(::Foo, x::Int) = x
getproperty (generic function with 24 methods)
julia> Foo().1
ERROR: syntax: extra token "0.1" after end of expression
Stacktrace:
[1] top-level scope at REPL[11]:0
Is there any documentation about what types can (or should) be used?
Note that :true === true, like for integers a quoted Bool is equal to itself. But Foo().true can work directly, as there is no parser ambiguity like with Foo().1. On the other hand, :nothing is a Symbol, i.e. :nothing !== nothing.