In python one can use the
I never found a way to do this in S4. But this is certainly possible in R6 objects. It is called Active binding.
R6 objects allow accessing attributes and calling member methods directly from the object instance with the
$operator, similar to other OOP languages like Java and C++. This allows for much more natural OOP code in R than it is possible with S3 and S4 objects.