Hacker Newsnew | past | comments | ask | show | jobs | submit | marvy's commentslogin

the full story is in the language reference, but the short answer is: __radd__ (unless it's more complicated than I realize)


Yes, the next level of complexity is that `a + b` will sometimes fall back to `b.__radd__(a)` if `a.__add__(b)` returns `NotImplemented`. But also:

- There are situations where `__radd__` takes priority over `__add__`. The rules for determining that priority are complex (and IIRC subtly different from the rules that determine whether `a < b` prioritises `a.__lt__(b)` or `b.__gt__(a)`).

- The lookup of `__add__` etc uses a special form of attribute lookup that's neither equivalent to `a.__add__` nor `type(a).__add__`. This special lookup only searches `type(a)` whereas the first would find an `__add__` function on `a`, and the second on `type(type(a))`.

I've also heard of further complications caused by implementation details leaking into the language semantics - for example, see Armin Ronacher's blog post: https://lucumr.pocoo.org/2014/8/16/the-python-i-would-like-t...


you can choose; there's an option buried in settings somewhere


But, there's no ability on a per-message basis. If they have their phone set up with iMessage, I cannot just send them an SMS if they lose their data connection.


Clever! I like this! I feel a bit jealous that I didn't think of it :)

It's not quite as easy as it seems, because these methods are "intrinsics". That is, the pure Java code you see is not always the one that gets used; instead, the JIT compiler can use a faster implementation that uses vectorized assembly or whatever. (That's why you see "@IntrinsicCandidate" on compress() and toBytes() in StringUTF16.java)

But I think your idea would also be possible to implement in vectorized assembly, so it still works!

The rule for most things (such as ArrayList) in the JDK is: "if you use race conditions to break this thing, that's your problem, not ours". But String is different: it's one of the few things meant to be "rock-solid, can't break it even if you try", so I think this bug in String would qualify as a potential security issue in their mind: there are many places in Java that trust Strings not to act weird, and some of them are even in native code deep in the guts of the VM.

On the other hand, String is used all over the place so having to introduce a performance regression to fix this bug would be quite painful. All of the other proposed solutions in this thread introduce an extra copy, and an extra pass over the string. Your fix is basically no extra cost, and as a bonus, can be tweaked so each char in the array is read only once.

Which means that the bug can now be fixed "guilt-free", if anyone from the JDK team is reading this thread. Though they have some pretty clever people there too, so they might have thought of it eventually for all I know.


I feel like there's two sides to this. On one hand, I agree with Zulip: don't make promises you're not sure can keep. On the other, you also shouldn't believe promises if the person making them is obviously not in a position to guarantee.

Example: suppose I offer you free email hosting "forever". Should you believe me? What if I go out of business? Well, in that case, I can at least ensure that your email address gets transferred to a different provider, so I'll still have kept my promise. So maybe this particular promise is believable.

But that only works because email is more or less a standard so there are many providers. Suppose I offer something that no one else does. Can you trust my promise that it will be "free forever"? Clearly, if I go out of business, then no.

Can I at least make a conditional promise that it will be free "as long as I'm in business"? But suppose I'm a month from bankruptcy, and my accountant tells me that getting rid of my free tier would save me. Surely, it's better for my free users to lose service rather than ALL my users losing service. So, unless you're sure I'd never be in that situation, you shouldn't believe me when I say "as long as I'm business this will be free".

Okay, how about a vague promise like "this service will keep its free tier around unless the business is in a desperate situation of some kind"? That's a promise that I could indeed keep, if I decide it's important enough... unless... how sure are you that I'll remain in full control of what is currently "my" business? What if I take my company public? I might then be kicked out by the board. (It happened to Steve Jobs, right?) So either my "free forever" promise means I'm not allowed to go public, or at least I need to do some very careful legal acrobatics to ensure that the board can't go back on my promise, even if they kick me out.

Still, if you find yourself needing to break a promise you made about "forever" a mere month after you made it, you should probably at least apologize instead of just hoping that no one remembers that you ever made such a promise. Chances are, they will indeed remember. If "it's the right thing to do" is not enough motivation, then do it for the brownie points, you'll get more of them this way. ("Who cares about brownie points?" you ask? Well, clearly, if they weren't worried about brownie points then they wouldn't be playing this weird game of "let's pretend we never said the forever".)


Thanks for the above. (nice self-restraint in the last paragraph.) Things almost make sense now. Except one problem ... this implies that there are software developers who think to themselves "given a cell phone number, how can I get the phone's location?".

And it further implies that these people don't immediately follow that thought with: "That's surely impossible, since it would be a privacy nightmare if literally everyone in the world could track everyone else in the world's every move".

Or perhaps with this alternative thought, which would lead to the same conclusion: "let's not worry about privacy, how would this even work? Does every phone company in the world pro-actively send every customer's location data to OpenCage, just in case someone queries it? Or does OpenCage wait until it gets a query, and only then query the cell phone company 'just-in-time'? Both of these sound like a lot of work for each phone company to support ... what's the incentive?"

Honestly, I'm a bit surprised that the OpenCage blog post is so calm about this, instead of just yelling incoherently "why WHY why would anyone think like this?!?"


I thought it was settled in Version 4. Compare:

https://www.tuhs.org/cgi-bin/utree.pl?file=V3/man/man2/time....

vs

https://www.tuhs.org/cgi-bin/utree.pl?file=V4/man/man2/time....

EDIT: note that back then, it was a signed integer. Turns out that people wanted to be able to represent dates from before 1970 so we lost one bit.


My fuzzy memory had me thinking it was version 6, thanks for the correction!

> note that back then, it was a signed integer.

Still and always is. We'd be having a 2106 problem instead of 2038 if it was unsigned 32-bit.


sorry I meant it was an UNSIGNED integer back then


How would a boyfriend or lack thereof even come up in an interview? Let alone so often as to be worth practicing such a thing? (I'm single, but I don't remember ever mentioning it in an interview. Though my memory is bad at this stuff so for all I know I've mentioned it every single time.)


The small talk will get you. It's less about the boyfriend and more about not letting them know I liked women. So I'd practice so I wouldn't accidentally say, "My interest in X started when my girlfriend and I went to Y." Or when someone mentions their wife/husband and then asks you about yours/your kids. (VERY common if you're a woman above 25; my impression is that men are not expected to divulge their childed status or lack thereof immediately socially [including in professional contexts], whereas women are).

Also you have to go over your bag, clothes, car, etc. and get rid of anything that could out you.

I eventually landed on "I don't date" as my official presentation, but after about 25, that starts looking really weird too. If I ever have to go back into the closet now, I'd probably claim to be divorced or widowed. "Traumatized by a bad marriage" is still easier for lots of people than "rug muncher".


Why would you want to work somewhere where you are rejected for what you are ? Just say you've got a girlfriend if it's coming in the conversation and if you don't get the job because of it, well, you just avoided working for years in a toxic environment.


Because I was in my 20s with no financial support and being in the closet at work beat being homeless. Especially as a visually impaired female. That's a one way ticket to ending up raped in a ditch. Pass.


Thanks for explaining. I guess if you ever decide to become a foreign spy, you can point to this as "relevant experience" in THAT job interview. Or something.


New York presumably


Why does it need a champion? Suppose some legislator is drunk one night and decides to introduce a bill banning non-competes. Who would vote against it?


> Who would vote against it

Every politician sponsored by a large corporation


isn't it?


> isn't it?

No, it isn't.

I get a popup blocking the article, reading

"Already a subscriber? Sign in

You’ve run out. You’ve read your last complimentary article. Become a New Yorker subscriber, plus get a free tote. Cancel anytime."


"You’ve read your last complimentary article. Become a New Yorker subscriber, plus get a free tote. Cancel anytime."


Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: