-
Notifications
You must be signed in to change notification settings - Fork 285
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
ResourceRetriever and Resource methods are now const #532
Comments
I though the methods, Above is my understand so far, and I would prefer to keep the consistency of the use of cost correctness. However, I'm not sure which one is practically preferred way. |
I don't think
|
I don't think that Here, the We can never make any guarantees about remote calls. Making the same remote call twice might yield different results just because the file on disk changed, or the server drops an HTTP call, or any number of arbitrary conditions unrelated to our code, but I don't think that violates the As long as we do not change the internal state of our program as a result, and we will follow the exact same logic when we make that call again, I think we can call these |
I think there's a compelling enough case for them to not be So far our approach to const-correctness has been "as long as every function you call is a My conclusion would be that, even though a user might reasonably expect that |
Hmm, I guess @mxgrey and I are just on different sides of the argument: "Is it reasonable to expect a On my side, I think that it is OK that it does not, as long as it uses the same exact deterministic logic to generate the result each time, and the C++ object does not change state. But Grey thinks that the existing If there is such a convention already, then we should go with that. |
I generally agree with @mxgrey here. As a higher level point, remember that I'm not comfortable making that commitment for all possible implementations of the interface. |
I now agree with that |
Can we close this now? |
It looks like #517
const
-qualified all of the methods on theResourceRetriever
andResource
classes. I intentionally left these non-const
when I added these classes in #464 so the user can implement a cache in his or her custom implementations. This is important when retrieving resources over the network or when resolving the URI is computationally expensive.I just ran into this situation myself and had to make a bunch of my member variables
mutable
as a workaround. I don't see any advantage to making these methodsconst
, so I would prefer to remove theconst
-qualifiers added in #517.The text was updated successfully, but these errors were encountered: