Better HN
topnewbestaskshowjobs
Log inSign up

wfunction

3,901 karma · joined Oct 15, 2012 (14y ago) · 1,547 submissions

Submissions

comment 9y ago · link · parent

Thank you for taking the time to write this!!

comment 9y ago · link · parent

Yeah, you're saying more or less what I was thinking here. https://news.ycombinator.com/item?id=13356101 Indeed I should've written it in the original comment.

comment 9y ago · link · parent

> What's the drawback for a const member?

Check out this subthread: https://news.ycombinator.com/item?id=13356101

comment 9y ago · link · parent

> Fair point, I was indeed being insufficiently precise. That code is a typical example of how const helps performance

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

Nobody said it doesn't "matter" whether you put const. I was saying it's not worthwhile.

comment 9y ago · link · parent

> However, the reason I didn't provide a citation is because the OP already gives an example - blink::serializedCharacterData gets moved over the read-only data segment if you add const, with obvious consequences for, say, thread-local accesses in tight loops.

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

Not sure why you replied to my comment (seems like an unrelated comment?), but anyway, this should work too; you shouldn't need a constructor:

  struct { const int x; } y = { 1 };

comment 9y ago · link · parent

You're gonna need a citation (preferably, an example) for the performance claim.

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

In my experience you should NEVER have const instance fields. Ever. If you want a const reference, just make a pointer to const. If you need a const value, just leave it mutable and access it through a const getter or work around it some other way. The language just doesn't seem to have been designed to make this particular feature actually worthwhile.

comment 9y ago · link · parent

Is it possible to show what XSLT is and why it's useful in like 5 minutes? I've always wanted a transformation language of some sort, but I've never managed to figure out XSLT (probably because I've never needed it) so I don't know what problems it solves or doesn't solve.

comment 9y ago · link · parent

I was disappointed after reading the title when I saw the article...

comment 9y ago · link · parent

I didn't say obvious cases are nonexistent. I merely said not all cases are obvious (and the non-obvious fraction is not negligible).

comment 9y ago · link · parent

It's not obvious to me what the difference is between "manual" modification as opposed to "automated" modification. Surely all of them rely on looking at the search terms in an automated fashion and then deciding (or rather, weighing) what to return?

comment 9y ago · link · parent

Would you have any links to articles about this? I'd like to read more.

comment 9y ago · link · parent

Well, I'm not literally an idiot either. Your fallacy is that I'm worried about Musk's business encountering a shortage of lithium. I'm not. I'm only wondering if a massive worldwide transition to lithium-based batteries triggered by his move might cause or otherwise encounter a lithium shortage in the foreseeable future (say, 40 years from now). This is not a worry about him or his business, this is a worry about the longer-term effects quite beyond that.

comment 9y ago · link · parent

When I saw their buildings I literally thought "I didn't know doors could be this big".

comment 9y ago · link · parent

Question: How much lithium can we rely on being able to extract for the foreseeable future? Do we not have a shortage of any kind?

comment 9y ago · link · parent

Does use of this [1] information not include attempting to match up the user's real-life name with his/her Facebook name?

[1] https://www.facebook.com/help/494750870625830

comment 9y ago · link · parent

In theory at least, you're supposed to look at what is being said rather than who is saying it...

Not at all claiming I always do that myself, but some food for thought.

comment 9y ago · link · parent

Thing is, if I had to guess, I would say Facebook doesn't attempt to make you use your real name to make the community better in the first place. That's almost certainly just its pretext for everyone who's willing to fall for it. Most likely, it does that to make sure it can identify you globally and uniquely for commercial/advertising purposes. Think about how much more valuable your online identity is if you go solely by Jon Doe rather than by foolover123, bar456fudger, and nighthowler789?

comment 9y ago · link · parent

I don't get it, you have to save and restore all the state on context switches either way. The only question is whether you're doing it with a generic instruction or through some other more specialized instructions. It's not a question of whether they should be saved and restored at all.

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 don't remember how many there were for AVX, but let's say there are 8 512-bit registers (4 KiB)? and then equivalent in other kinds of registers, so 8 KiB. Just an order-of-magnitude estimate, nothing I expect to be too accurate.

comment 9y ago · link · parent

Ah yes, good find, I believe this was one of them! I don't remember if there were more though, there might have been.

comment 9y ago · link · parent

Any idea how much it is? (just as a guess, I'd guess like maybe 8 KiB?)

comment 9y ago · link · parent

That doesn't mean the CPU can't report the size necessary using another instruction though. There's no need for the OS code to change.

comment 9y ago · link · parent

Oh wow. When did this change? I vaguely seem to remember that as recently as Windows 7 (or was it 8.0?) there was trouble with AVX2 or something, but I can't find the info anywhere at the moment.

comment 9y ago · link · parent

Something that's always baffled me: why don't CPUs have a "save ALL state" and "restore ALL state" instructions? Why does every new set of CPU registers seem to require an OS update to save them on context switches?

comment 9y ago · link · parent

Plausible deniability?

comment 9y ago · link · parent

It's "LexisNexis"... it's not referring to the nexus of a car company. :)

comment 9y ago · link · parent

EDIT: Whoops! I just realized the entire point of this problem was missed, and it's my fault -- I worded my comment pretty poorly in hindsight.

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.

1
171819
52