-
Notifications
You must be signed in to change notification settings - Fork 827
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
Suggestion: override
for derived classes
#639
Comments
I like it. |
I can do a PR if you would like to ? |
Sure. Let's go ahead and drop this in the You will need to update all code and all instances in the three books. In addition, please work with @trevordblack, as he is in the middle of running through book 2 for an image update pass, updating numerous code issues as he goes. |
Also, I keep getting confused with real names versus GitHub user IDs — have you been added to the acknowledgements yet? (https://raytracing.github.io/books/acknowledgments.md.html). At this point, I think I should be linking a lot of these names to associated GitHub user pages. |
I tried adding the |
The big thing here is that the All code changes need to go into the book. We've not been diligent about this in the past, but going forward, that's our plan. If you want to tread forward, you can try to add override to both the source and text, or you can just do the source, or you can just do the text. What are your thoughts? Steve started the renders for book2, I'm going to finish up, but in going through the renders we're literally copying the inline source from the text into the code to make the renders. |
In that case I'll add both to code and to text of book 3, since it is not rendered yet, and to the code of book 1 as well. I hesitate to touch upon the text of book 1 since it is quite popular. For book 2, I can change the text, so that it is copied to source during rendering. How does that sound ? |
You'll be making changes to our minor-change branch, not to the live branch. We'll have ample time to review your changes and make sure everything's coordinated. Also note that when we talk about the "text of the book", we are referring to the code listing fragments in each book. You're correct that there shouldn't be any issues with either book 1 or book 3. I'd recommend that you also make changes to book 2. Trevor can then rebase his progression branch onto the updated |
"override" qualifier is added to all derived classes. The qualifier is also added to the text of the book. All the code compiles and no runtime error during the execution. I have only tested the three main executables: inOneWeekend theNextWeek theRestOfYourLife Fixes RayTracing#639
Everything that affects this issue has been fixed for |
I am still up to adding the qualifier, but I have noticed that dev-minor was quite active in the recent weeks, so I waited for everything to settle down a bit. But if you think it is not necessary to add the qualifier, I can drop the idea as well |
Still think it's a good, easy idea. Go for it. |
Any chance you could get this done this weekend? I'm hoping to wrap up my two remaining issues and get v3.2.0 out the door. |
Oops. ↑ @D-K-E |
Thinking out loud, here, what's the viability and utility of turning some of the parent functions into purely virtual functions? |
|
So about five non-pure-virtual functions. Note that 78 overrides total, by my count. Still, I think that flagging everything with override still helps the reader. |
(This class hierarchy is pretty helpful. Might be nice to squirrel that away somewhere.) |
I've come this far — I'm just going to whip this out... |
@hollasch or I can get it done in weekend ... Your wish is my command ... |
This just in: using the |
Good grief. Book 2 has a So the code for book three actually used the default Filed as issue #669. |
It looks like the only non-pure virtual function that isn't introduced in book 3 is emitted. I think we should consider removing all non-pure virtual functions. If so, emitted should go in 3.2.0 |
@trevordblack — I'm not understanding why default implementations are bad. Better than copy-pasting implementations, and I'm definitely not up for laying the groundwork for more whack-a-mole branching updates. |
Hmm. I guess this was the reason the There's nothing wrong with default implementations. I'm just used to having interface style purely virtual classes. |
This might seem rather unnecessary, since if the reader is careful, overriding methods of the base class shouldn't be a problem. However I noticed that it took me quite a while to track down the bugs related to this problem. An
override
qualifier can add an extra layer of warning for such bugs.I am basically suggesting to turn this:
to this:
The text was updated successfully, but these errors were encountered: