-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default constructor could take instance as first argument #229
Comments
You can do this currently with |
@lawremi Which of the following syntaxes would you prefer? set_props(obj, x = 1, y = 2)
set_props(obj, list(x = 1, y = 2)) The first is more user friendly but there's no obvious way to supply a list. In the tidyverse we'd use "dynamic dots" here, so you could do |
Hmm, I never got why |
@mmaechler sometimes you want to create a modified copy of the object, rather than modifying in place. |
methods::initialize()
takes an instance of the class (or subclass, in which case extra slots are dropped) as the first argument, and named arguments specify the slot values, overriding those of the first argument. This behavior has proven convenient for creating derivative objects. I wonder if the default constructor could behave similarly. This would often force property arguments to be named in calls to the constructor, but that at least benefits clarity.I wonder though whether this is a feature that most benefits implementations, and so should instead be supported by a different function, like
set_props()
, which would just be a simple wrapper aroundprops<-()
.The text was updated successfully, but these errors were encountered: