New features
-
The default object constructor returned by
new_class()
has been updated.
It now accepts lazy (promise) property defaults and includes dynamic properties
with asetter
in the constructor. Additionally, all custom property setters
are now consistently invoked by the default constructor. If you're using S7 in
an R package, you'll need to re-document to ensure that your documentation
matches the updated usage (#438, #445). -
The call context of a dispatched method (as visible in
sys.calls()
and
traceback()
) no longer includes the inlined method and generic, resulting in
more compact and readable tracebacks. The dispatched method call now contains
only the method name, which serves as a hint for retrieving the method. For
example:method(my_generic, class_double)
(x=10, ...). (#486) -
New
nameOfClass()
method exported for S7 base classes, to enable usage like
inherits("foo", S7::class_character)
(#432, #458) -
Added support for more base/S3 classes (#434):
class_POSIXlt
,
class_POSIXt
,class_formula
,class_call
,class_language
,
andclass_name
. -
S7 provides a new automatic backward compatibility mechanism to provide
a version of@
that works in R before version 4.3 (#326).
Bug fixes and minor improvements
-
new_class()
now automatically infers the package name when called from
within an R package (#459). -
Improved error message when custom validators return invalid values (#454, #457).
-
Fixed S3 methods registration across packages (#422).
-
convert()
now provides a default method to transform a parent class instance
into a subclass, enabling class construction from a prototype (#444). -
A custom property
getter()
no longer infinitely recurses when accessing
itself (reported in #403, fixed in #406). -
method()
generates an informative message with class
S7_error_method_not_found
when dispatch fails (#387). -
method<-()
can create multimethods that dispatch onNULL
. -
In
new_class()
, properties can either be named by naming the element
of the list or by supplying thename
argument tonew_property()
(#371). -
The
Ops
generic now falls back to base Ops behaviour when one of the
arguments is not an S7 object (#320). This means that you get the somewhat
inconsistent base behaviour, but means that S7 doesn't introduce a new axis
of inconsistency. -
prop()
(#395) andprop<-
/@<-
(#396) have been optimized and
rewritten in C. -
super()
now works with Ops methods (#357). -
validate()
is now always called after a custom property setter was invoked
(reported in #393, fixed in #396).