3,901 karma · joined Oct 15, 2012 (14y ago) · 1,547 submissions
comment 9y ago · link · parent
comment 9y ago · link · parent
Check out this subthread: https://news.ycombinator.com/item?id=13356101
comment 9y ago · link · parent
OK, well, I was merely saying you need a citation for the situation we were discussing. I still stand by it.
> I think the MSVC devs classify it as a codegen bug since the cause is a logic error in the optimizer.
I'm gonna pull your own type of argument here, which is that they only consider it a bug because they have their own stricter guidelines for what they expect, not because it's actually a general language implementation bug. Definitely not something I'd call an "outright compiler bug" when the code is behaving sanely.
> When you say using const has given you trouble many times, do you have any particularly poignant example in mind?
I don't have a particularly poignant one at the top of my head right now, but I can give you a hypothetical one to illustrate the idea. Look at std::binary_negate (for our purposes assume the functor is required to be const-callable). People put const on the instance field of that sort of thing because, well, everything that can be const should be const dammit! Except now it gives you hell trying to assign to the object. That's the issue.
comment 9y ago · link · parent
Uh, that wasn't an instance field, was it? https://codereview.chromium.org/2608823002/diff/20001/third_...
> That's an outright compiler bug, not a general language reason.
It's not a bug, just a missed performance optimization. The code behaves correctly.
And I was merely responding to your comment, "I can't imagine a single reason to tell people not to use const instance fields."
The underlying language reason I have for it is not something you may agree with, but it's that it Seems Wrong (TM) to me for the fields of a class to dictate how the class's instances can be constructed or assigned to. Again, I don't claim I can convince you here. It just seems like poor design to me, and it's given me trouble so many times without once actually providing me a benefit. So it's a reason. YMMV.
comment 9y ago · link · parent
As for this comment of yours:
> I can't imagine a single reason to tell people not to use const instance fields.
That's weird, did you not read the blog post? It literally gave you a reason not to, you don't need to imagine anything. If you don't think it's a compelling reason then that's another story, but it's a valid reason.
comment 9y ago · link · parent
comment 9y ago · link · parent
comment 9y ago · link · parent
comment 9y ago · link · parent
comment 9y ago · link · parent
That said, I'm confused why you replied to my comment above, since it's totally off-topic. This thread chain was asking how much state exists; maybe you were trying to reply to another thread?
comment 9y ago · link · parent
I meant to say that STEM college graduates ought to be able to solve problems such as this one. That would include less-trivial instances, like the light-ray example I gave in another comment where you have to find the path that light travels when it crosses between media with different velocities. Unfortunately I made the mistake of posing the most trivial instance of this kind of problem as an example (Euclidean vector space), which resulted in many people missing the point I was trying to make. Sorry about that. The point wasn't solving this specific problem, the point was this kind of problem, and my example was overly simplified and therefore not representative of what I was trying to convey.
With that aside, note that this is still not a basic geometry problem, since you need to be able to discuss the lengths of arbitrary smooth curves, not just lines/angles/circular arcs.