You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To me, the question is more about what constitutes the structure, str(), of the object? Are dynamic properties part of the structure? Users will not care about whether a property is dynamic or not; they just see them as properties, so I think the answer is "yes." It would be surprising for a property not to show up in str().
This reminds of the deprecated property case though. It would be annoying to get a warning every time the object is printed, so there would need to be a custom str() method. Or, we add formal support for property deprecation that effectively hides them.
Possibly both are right: str() should mention properties by default. OTOH, its S7_object method get an option to suppress them. Then the print() method may in some cases use that suppression option ..
For the deprecated property case, if class authors truly want to deprecate a property, they'll also want to implement a print() method that doesn't show the deprecated property. Alternatively, they can include conditional logic in the getter to suppress warnings when called from print, like this:
getter=function(self) {
warn<-TRUEfor (clin sys.calls()) {
if (cl[[1]] == quote(print.S7_object)) {
warn<-FALSEbreak
}
}
if (warn) {
warning("@foo is deprecated")
}
self@newfoo
}
Activity
lawremi commentedon Sep 28, 2024
To me, the question is more about what constitutes the structure,
str(), of the object? Are dynamic properties part of the structure? Users will not care about whether a property is dynamic or not; they just see them as properties, so I think the answer is "yes." It would be surprising for a property not to show up instr().This reminds of the deprecated property case though. It would be annoying to get a warning every time the object is printed, so there would need to be a custom
str()method. Or, we add formal support for property deprecation that effectively hides them.mmaechler commentedon Sep 29, 2024
Possibly both are right: str() should mention properties by default. OTOH, its S7_object method get an option to suppress them. Then the print() method may in some cases use that suppression option ..
t-kalinowski commentedon Oct 7, 2024
I think we can default to calling
print()withsuppressWarnings(), to handle the deprecated property case.t-kalinowski commentedon Oct 10, 2024
For the deprecated property case, if class authors truly want to deprecate a property, they'll also want to implement a
print()method that doesn't show the deprecated property. Alternatively, they can include conditional logic in the getter to suppress warnings when called fromprint, like this: