Skip to content
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

Possible fixes to FunctionPointer PR (#28) #30

Open
bogdanm opened this issue Jun 10, 2015 · 5 comments
Open

Possible fixes to FunctionPointer PR (#28) #30

bogdanm opened this issue Jun 10, 2015 · 5 comments

Comments

@bogdanm
Copy link
Contributor

bogdanm commented Jun 10, 2015

#28 introduced a number of questionable changes:

  • the clear method in FunctionPointerBase and FunctionPointerBind. This was introduced because it looks like it might be needed in MINAR. If it turns out that it's not, clear needs to be removed.
  • private virtual destructor in FunctionPointerBase (following the already present private constructor). With that in mind, It might be that FunctionPointerBind and FunctionPointerX should not inherit from FunctionPointerBase, but rather include it, using composition (and a proper name change). This isn't an error, just a possible improvement if it turns out to be the right idea.
@autopulated
Copy link
Contributor

Can you assign an uninitialised object instead of clear()-ing?

If the destructor needs to be virtual, then it should be public, I think?

@bogdanm
Copy link
Contributor Author

bogdanm commented Jun 10, 2015

Yup, that's why I thought that composition might be the better option here. After all, if both your constructor and destructor are protected, you're not expecting to ever cast your reference to the base class (which is the intended behaviour here), so that's not really an is-a relationship.
About assigning an unitiliazed object, that'll work, but I don't think the code will look much better.

@autopulated
Copy link
Contributor

Actually, how would virtual inheritance even work here. Won't we always pass these objects around by value?

@bogdanm
Copy link
Contributor Author

bogdanm commented Jun 10, 2015

It would technically work, except you're not even supposed to use the base class directly. Yet another reason to think that inheritance is the wrong mechanism. That was actually protected inheritance initially, which is a bit better, but I still think composition is preferable to that.

@bremoran
Copy link
Collaborator

Composition should be okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants