r-lib / R6

Encapsulated object-oriented programming for R
https://R6.r-lib.org
Other
410 stars 56 forks source link

new() gets formals from initialize() #191

Closed wch closed 4 years ago

wch commented 4 years ago

Closes #104. This is a modification of #103, but with code that is a bit easier for me to understand.

Now new() doesn't just take ...; it gets its arguments from the initialize() method.

One exception is when a subclass doesn't define its own initialize method. In that case, new() just takes ... and passes them along to the superclass's initialize(). This is because the inheritance is resolved when new() is called, not when the class is defined, so the content of the superclass's initialize() method cannot be known before new() is called.