← Home ← Back to /g/

Thread 105947817

115 posts 32 images /g/
Anonymous No.105947817 [Report] >>105947848 >>105947911 >>105947942 >>105948187 >>105948399 >>105948444 >>105948996 >>105949379 >>105950911 >>105951183 >>105952108 >>105952689 >>105954276 >>105955387 >>105956214
>+=1 isn't good enough. lets add an entire operator to my language just for that
mental illness
Anonymous No.105947848 [Report] >>105947877 >>105947891 >>105948899 >>105949042 >>105951843 >>105955224
>>105947817 (OP)
n++ and n+=1 are not equivalent
n+=1 is equivalent to ++n

At least be right if you're going to make a post like this.
Anonymous No.105947872 [Report] >>105948932 >>105951829 >>105954191
some architectures have an instruction that does this doe
Anonymous No.105947877 [Report] >>105947891
>>105947848
>n+=1 is equivalent to ++n
No, n+=1 is not an rvalue. whereas ++n is.
At least be right if you're going to make a post like this.
Anonymous No.105947891 [Report] >>105947931 >>105951855
>>105947877
>>105947848
both wrong. n++ is 2 operation in one. Return n, and then add
Anonymous No.105947903 [Report] >>105952552
for loops are bloat, just use while loops
Anonymous No.105947911 [Report]
>>105947817 (OP)
>n = n+1 isn't good enough. let's add an entire operator to my language just for that
Anonymous No.105947931 [Report] >>105947956
>>105947891
Please elaborate how my statement
>++n is [an rvalue]
is wrong. You have my undivided attention.
Anonymous No.105947942 [Report]
>>105947817 (OP)
++n and n++ are different constructs
Anonymous No.105947956 [Report] >>105948010 >>105948442
>>105947931
++n is not an rvalue in C++. It's a modifiable lvalue, which is why you can do things like

>++n = 5;

In C, ++n is indeed an rvalue.

n + 1 is always an rvalue in both languages and has no side effects.

So no, ++n and n + 1 are not equivalent, neither in value category nor behavior.
Anonymous No.105948010 [Report] >>105948060 >>105948324
>>105947956
>In C, ++n is indeed an rvalue.
I accept your concession and I am awaiting your apology.
Anonymous No.105948060 [Report] >>105948208
>>105948010
since we never stated the language, you can keep awaiting
Anonymous No.105948187 [Report] >>105952994
>>105947817 (OP)
Dumb shit
just do
>inc RAX

Done
Anonymous No.105948208 [Report] >>105948228
>>105948060
Since we never stated the language, your original statement
>both wrong
was premature, wasn't it.
Anonymous No.105948228 [Report]
>>105948208
>Since we never stated the language, your original statement
>>both wrong
wrong
Anonymous No.105948304 [Report]
Rust doesn't have this problem.
Anonymous No.105948324 [Report]
>>105948010
Literally just entered this thread and read 0 posts. I accept your concession in advance. You may kiss my feet now.
Anonymous No.105948330 [Report] >>105948370 >>105948373 >>105948391 >>105948472 >>105948736 >>105948897 >>105951054
>+=1
mental illness, use n = n + 1
Anonymous No.105948370 [Report]
>>105948330
>n = n + 1
Lua user spotted.
Anonymous No.105948373 [Report]
>>105948330
this but unironically
rest is bloat
Anonymous No.105948391 [Report] >>105948476 >>105952915
>>105948330
oof using the same variable on both sides of the assignment operator? Very confusing.
Better to do:
new_var = n + 1; n = new_var
Anonymous No.105948392 [Report]
>these are the subhuman intellects crying that they can't get a programming job anymore
Anonymous No.105948399 [Report]
>>105947817 (OP)
stay away from computers
Anonymous No.105948422 [Report] >>105948497 >>105954075
>comp sci 101
>devolves into brainlets arguing like its a 300 IQ problem
Anonymous No.105948431 [Report] >>105948510 >>105951793 >>105952640 >>105952669
++ -- are code smells
Anonymous No.105948433 [Report]
ACKCHYUALLY C had ++ -- operators because they transleted to cheaper/smaller instructions for increment/decrement than arbitrary addition; and there was no optimizing compiler and they were either too constrained or lazy to detect right-hand-size. it's a bit of a historical artifact that became redundant as soon as compilers started to have at least minimal optimizations
Anonymous No.105948435 [Report]
n+=1 is garbage too, i hate these in-place operators
for me it will always be n=n+1
Anonymous No.105948442 [Report]
>>105947956
picrel is bjarne dabbing on cniles
Anonymous No.105948444 [Report]
>>105947817 (OP)
It was added cuz the PDP-11 had support for it.
Anonymous No.105948470 [Report] >>105948875 >>105951978
>i++
>i+=1
>i.inc()
>i = i + 1
Which one do you prefer the most, /g/?
Anonymous No.105948472 [Report]
>>105948330
Are you insane?!?
*pn = NULL;
n = 0;
pn = &n;
n = (*pn)++;
Anonymous No.105948476 [Report] >>105952007
>>105948391
Good morning saar.
Anonymous No.105948497 [Report] >>105954075
>>105948422
>Not even comp sci
>Feeling this insecure about a shitpost thread
The nocoder has outed himself once again.
Anonymous No.105948510 [Report]
>>105948431
Snopes verdict: false
Anonymous No.105948654 [Report]
brevity is wit
Anonymous No.105948736 [Report] >>105950324
>>105948330
This, but n := n + 1
Anonymous No.105948875 [Report]
>>105948470
INCF i, 1
Anonymous No.105948897 [Report]
>>105948330
for me its set n (math '$n + 1')
Anonymous No.105948899 [Report] >>105948923
>>105947848
Compiler: *optimizes all of these into the same thing* Heh, nothin' personnel kid
Anonymous No.105948923 [Report]
>>105948899
you need to use a new compiler
Anonymous No.105948932 [Report] >>105953985
>>105947872
some compilers can understand when you're adding one
Anonymous No.105948957 [Report] >>105948961
What about n *= m, n /= m, n%= m, etc?
Anonymous No.105948961 [Report]
>>105948957
What about them?
Anonymous No.105948996 [Report] >>105954033
>>105947817 (OP)

(setq n(1+ n))
Anonymous No.105949042 [Report] >>105949167 >>105955269
>>105947848
I have never used ++n in my career
Anonymous No.105949063 [Report] >>105949091 >>105949288 >>105956146
Why do useless threads like this are the ones that receives replies?
Anonymous No.105949091 [Report]
>>105949063
It's just a typical skub thread. Ni/g/gers love to bicker about pointless shit.
Anonymous No.105949167 [Report]
>>105949042
it's better for stl iterators. however, in recent years the main compilers will detect your skin color and fix it in the assembly
Anonymous No.105949288 [Report] >>105950153
>>105949063
It's kind of fun. Entry level, but you still need to know something to participate. Should we just do another brand warz or ai thread instead?
Anonymous No.105949379 [Report]
>>105947817 (OP)
>post-increment
>post-
Anonymous No.105950153 [Report]
>>105949288
It's the same pointless tribalism, did anons forgot how to normally talk to each other?
Anonymous No.105950324 [Report]
>>105948736
>:=
ngmi
Anonymous No.105950370 [Report] >>105950424
its so u can do stuff like auto x = *ptr++. or auto x = a[ind++]. saves an extra line. ++x will increment before so say int a = 5; int b = ++a; they will both be 6. however if int a = 5; int b = a++ b will be 5 and a will be 6. n+=1 is the same as n = n + 1, so it cannot be used in expressions.
Anonymous No.105950424 [Report] >>105950805 >>105952596
>>105950370
>saves an extra line
Peak mathcuck mentality, saving lines over being easy to read.
Anonymous No.105950805 [Report] >>105950932
>>105950424
you mean your machine doesnt have a finite capacity of newline characters?
Anonymous No.105950911 [Report]
>>105947817 (OP)
Judging by the fact that literally nobody knows what this shit does without looking up the standard it probably shouldn't exist.
Anonymous No.105950932 [Report] >>105951004
>>105950805
Yeah, for all intensive purposes, that's right.
Anonymous No.105951004 [Report] >>105952002
>>105950932
I hole-hardedly agree, but allow me to play doubles advocate here for a moment. For all intensive purposes I think you are wrong. In an age where false morals are a diamond dozen, true virtues are a blessing in the skies. We often put our false morality on a petal stool like a bunch of pre-Madonnas, but you all seem to be taking something very valuable for granite. So I ask of you to mustard up all the strength you can because it is a doggy dog world out there. Although there is some merit to what you are saying it seems like you have a huge ship on your shoulder. In your argument you seem to throw everything in but the kids Nsync, and even though you are having a feel day with this I am here to bring you back into reality. I have a sick sense when it comes to these types of things. It is almost spooky, because I cannot turn a blonde eye to these glaring flaws in your rhetoric. I have zero taller ants when it comes to people spouting out hate in the name of moral righteousness. You just need to remember what comes around is all around, and when supply and command fails you will be the first to go. Make my words, when you get down to brass stacks it doesn't take rocket appliances to get two birds stoned at once. It's clear who makes the pants in this relationship, and sometimes you just have to swallow your prize and accept the facts. You might have to come to this conclusion through denial and error but I swear on my mother's mating name that when you put the petal to the medal you will pass with flying carpets like it’s a peach of cake.
Anonymous No.105951046 [Report]
>*(c+=1)
Anonymous No.105951054 [Report]
>>105948330
Hello sar are you crazy? Fuck you bloody bastard bitch. The correct syntax is:

Integer n;
String n2 = "0";
String n3 = "1";
n = Integer.parseInt(n2) + Integer.parseInt(n3);
Anonymous No.105951183 [Report]
>>105947817 (OP)
We need new features in C++ such that we can redefine operators.
#define n++ n+=1
Anonymous No.105951793 [Report] >>105951915 >>105952082
>>105948431
But code doesn't smell. I can imagine any smell I want when I look at code.
Anonymous No.105951829 [Report]
>>105947872
> some?
Almost all.
Pascal:
succ(n)
Anonymous No.105951843 [Report]
>>105947848
++n is 1 = 1 + n
n++ is n = n + 1
Anonymous No.105951855 [Report] >>105951984
>>105947891
cniles have lost their rights to make fun of rustroons
Anonymous No.105951915 [Report]
>>105951793
but you smell the jeets.
in the office on the other side of the building.
3 floors away.
Anonymous No.105951978 [Report]
>>105948470
i = 1; // optimisation: assumes that i is zero initially. should be true most of the time.
Anonymous No.105951984 [Report]
>>105951855
They seem to be getting more rights over rust developer’s own bodies.
Anonymous No.105952002 [Report]
>>105951004
I prefer the rotational velocidensity pasta desu
Anonymous No.105952007 [Report] >>105952014
>>105948476
sounds more like something Boomer Junion Wasperson III (freemason 2nd degree) would say
Anonymous No.105952014 [Report]
>>105952007
*Junior
Anonymous No.105952082 [Report] >>105952313
>>105951793
>>But code doesn't smell
>bing "code smell"
>ten trillion hits
Anonymous No.105952108 [Report]
>>105947817 (OP)
inc n
Anonymous No.105952111 [Report] >>105952116 >>105952587
>I am so much smarter than any compiler
>I write ++i instead of i++ in for loops because it generates 1.2 fewer instructions
literally all of you
Anonymous No.105952116 [Report]
>>105952111
*-O3's your path*
Anonymous No.105952313 [Report]
>>105952082
If that's how you judge what's real you're going to be a targeted individual soon.
Anonymous No.105952552 [Report] >>105952655 >>105954070
>>105947903
while loops are bloat, just use tail recursion.
Anonymous No.105952587 [Report] >>105955455
>>105952111
The compiler is not omniscient.
Anonymous No.105952596 [Report] >>105952627
>>105950424
i agree that it's pointless and stupid, but if you can't automatically parse ++ and += as the same unconsciously you have bigger problems
Anonymous No.105952627 [Report]
>>105952596
I like writing i++ a lot more than i += 1. I just hate reading code where they heavily rely on juggling the return values from ++ shit everywhere just so they can save a line.
Anonymous No.105952640 [Report]
>>105948431
Imagine the smell.
Anonymous No.105952655 [Report] >>105952925
>>105952552
it all ends up as jumps anyway
Anonymous No.105952669 [Report]
>>105948431
Yes, and it's not code that stinks good
Anonymous No.105952689 [Report]
>>105947817 (OP)
Postfix operators give you (non-atomic) exchange semantics. `+=` does not.
Anonymous No.105952915 [Report] >>105953754
>>105948391
I hate this because it sounds exactly like something some smug asshole high on his own farts would put in a company style guide and lecture you about.
Anonymous No.105952925 [Report]
>>105952655
not on my watch
https://github.com/xoreaxeaxeax/movfuscator
Anonymous No.105952994 [Report]
>>105948187
Based. Now what is it in RISC-V64
Anonymous No.105953754 [Report]
>>105952915
imagine not using clang-tidy in 2025
Anonymous No.105953939 [Report] >>105953944
Is it weird that I prefer
nCount++;
SomeFunction(sTest, nCount, nLimit, fCharge);
over
SomeFunction(sTest, ++nCount, nLimit, fCharge);
I feel like the first is more readable
Anonymous No.105953944 [Report]
>>105953939
preincrements are confusing. Only post increments should be used.
Anonymous No.105953985 [Report] >>105954229 >>105954352 >>105955393
>>105948932
Anonymous No.105954033 [Report]
>>105948996
while (++moron_counter < nigger_var--) { trashbin(++shitposters); }
or
moron_counter += 1;
while (moron_counter < nigger_var) {
shitposters += 1;
trashbin(shitposters);
nigger_var -= 1;
moron_counter += 1;
}
Anonymous No.105954070 [Report] >>105955490 >>105956552
>>105952552
you're going to overflow the stack tranny
Anonymous No.105954075 [Report]
>>105948422
>>105948497
>several hours later
>this retardation is still going
Anonymous No.105954191 [Report]
>>105947872
Yep, and on x86_64 it's unused. Even if you use i++, it will get replaced with an ADD instruction. INC is no faster than an ADD, but doesn't set RFLAGS
Anonymous No.105954229 [Report]
>>105953985
holy fuck stay away from computers, for the love of god
Anonymous No.105954276 [Report] >>105955337
>>105947817 (OP)
As a physicist I just say that literally everything is better than n=n+1. At least ++ and += have no meaning in mathematics.
Anonymous No.105954352 [Report]
>>105953985
Why do you expect code that has undefined behavior to not be broken by compiler optimisation? And bringing TCC to the mix isn't even fair because no optimisation.
Anonymous No.105955166 [Report] >>105955259 >>105955527
What does this function return?
int foo (void) {
int n = 0;
return ++n + n++;
}
You should be able to solve this.
Anonymous No.105955224 [Report]
>>105947848
>the utter state of the replies
cniles btfo
Anonymous No.105955259 [Report] >>105955419
>>105955166
Is it 1?
I remember I had this issue a while ago where I returned n++, but it didn't return the incremented value.
Anonymous No.105955269 [Report]
>>105949042
You use it for iterators, which are not required to support it++ as operation.
Anonymous No.105955337 [Report]
>>105954276
> n = n + 1
> n - n = 1
>0 = 1
>the universe implodes
Anonymous No.105955387 [Report]
>>105947817 (OP)
I use it only for for-loop
Anonymous No.105955393 [Report]
>>105953985
>look at me, I don't know C
https://www.gnu.org/software/c-intro-and-ref/manual/html_node/Signed-Overflow.html
Anonymous No.105955419 [Report] >>105955527
>>105955259
it's undefined behavior. any compiler is free to do whatever it wants with that expression.
In fact, gcc and clang will warn you if you try to do that.
Anonymous No.105955455 [Report]
>>105952587
all compilers will emit the same instructions for i++ and ++i unless you explicitly use the rvalue from i++. Notable exceptions being the first C (ansi C) compiler which didn't have optimizations and would emit fewer insn for ++i.
https://godbolt.org/z/WWrxjaTnq
Anonymous No.105955490 [Report] >>105955545
>>105954070
>tail recursion
>will overflow the stack
chatgpt levels of confidently wrong
Anonymous No.105955527 [Report] >>105955540
>>105955166
>>105955419
it will always return 2

if ++n evaluates first it, returns 1 and n is now 1
then n++ evaluates second, returning 1 and n is 2
1 + 1 = 2

if n++ evaluates first, it returns 0 and n is now 1
then ++n evaluates, returning 2 and n is now 2
0 + 2 = 2
Anonymous No.105955540 [Report] >>105955564
>>105955527
And yet
https://godbolt.org/z/1vMEEzqzW
Anonymous No.105955545 [Report]
>>105955490
I sure am glad to live in a world where tail call optimization is consistently implemented by all languages
Anonymous No.105955564 [Report]
>>105955540
damn
Anonymous No.105956146 [Report]
>>105949063
As opposed to what threads? Your shitty question that could be answered by an LLM and belongs in /sqt/? The trillionth brand war thread? Maybe the excuse of a thread to post weebshit?
Anonymous No.105956214 [Report]
>>105947817 (OP)
are you american by any chance
Anonymous No.105956552 [Report]
>>105954070
Are you genuinely retarded, or just pretending to be stupid for the lulz?