sniffnoy: (Default)
[personal profile] sniffnoy
<< has a lower precedence than + ?! Whose idiotic idea was that?!

On a less irritating note, another word that ought to exist:

ex•ply \ eks'plı̄ \ vt explied; explied; explying; explies [ By analogy with "imply" ] : To make explicit. ⟨I know it what obvious, but I wanted to ~ it so it could be official.⟩

In order to feed the hysterical porpoises, the credit for this one goes to Nick. Don't ask why.

Date: 2003-06-26 09:43 pm (UTC)
From: [identity profile] blenrock.livejournal.com
Umm, yeah << has lower precedence than +

Really, why shouldn't it? It makes sense to me...

Date: 2003-06-27 10:28 am (UTC)
From: [identity profile] sniffnoy.livejournal.com
Because shifting is multiplication, that's why. Surely it should have higher precedence than addition?

*checks chart*

Oh, it has higher precedence than & / | / ^ . Well, that makes sense, anyway. And if I had just used | instead of + in the first place there wouldn't have been that problem.

But I still think it should be higher than +.

Re:

Date: 2003-06-27 12:16 pm (UTC)
From: [identity profile] blenrock.livejournal.com
Yeah, but it also serves as the stream extraction operator... and that really needs to have low precedence. Unless somehow in the two contexts it could have different precedences...

Eh, I'm not computery enough to be discussing this.

Date: 2003-06-28 09:15 am (UTC)
From: [identity profile] sniffnoy.livejournal.com
Well, that's just in C++. I don't think operator overloading does allow you to change the precedence, but I don't really know C++, only C, but from what I remember of operator overloading there's no way to specify a new precedence (how would that work, anyway?) so presumably the precedence of these things is constant.

Anyway that's just in C++, which keeps the same precedences from C. So that still leaves the question of why shifting has a lower precedence than addition in C.

(I suppose it's because | already had lower precedence than << and >>, and they figured that would be more common in that context, and that if you used + with shifting, you probably wanted to... eh, who cares.)

January 2026

S M T W T F S
     123
45678910
11121314151617
18192021222324
25262728293031
Page generated Jan. 12th, 2026 01:48 am
Powered by Dreamwidth Studios