|
You will find the answer here: Comma operator - Wikipedia[^]
... and it is a programming question which should not be asked in the lounge as far I understand
[Edit]
I only know this beast because of a typo I made once
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
Doh! Never mind. Totally legal even though does not make any sense
|
|
|
|
|
Yep, see also my edit above
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
The syntax is commonly used in for loops where you want to, say, increment two variables typically two indexes, or stepping two linked lists) before the next iteration.
|
|
|
|
|
Quote: The syntax is commonly used in for loops where you want to, say, increment two variables typically two indexes, or stepping two linked lists) before the next iteration.
For me the syntax is used to make the code unreadable
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
0x01AA wrote:
For me the syntax is used to make the code unreadable it's called newbie proofing.
pestilence [ pes-tl-uh ns ] noun
1. a deadly or virulent epidemic disease. especially bubonic plague.
2. something that is considered harmful, destructive, or evil.
Synonyms: pest, plague, CCP
|
|
|
|
|
LOL, i'm guilty of using it in for loops sometimes.
Real programmers use butterflies
|
|
|
|
|
You'll be burned anyway, so what's the point?
And yes of course, I do not know / use the syntax and therefore most probably my negative attitude for it ...
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
It lets you declare multiple variables of the same type in a single statement.
int i=0,ic=10;
It's useful primarily for for() loops when you need multiple variable inits
Real programmers use butterflies
|
|
|
|
|
Member 7989122 wrote: The syntax is commonly used in for loops where you want to, say, increment two variables typically two indexes, or stepping two linked lists) before the next iteration.
Yeah, can also remember using it to save that extra effort of typing "curlies" after say an if () or while () or ...
- do everything in a single statement
- save wear and tear on the <shift> keys
- readability phhht, that's only for other people anyway. (Me: I can read my own mind!)
... Anyway I write code correct & bug-free first time, why does it need to be [re]readable?
pestilence [ pes-tl-uh ns ] noun
1. a deadly or virulent epidemic disease. especially bubonic plague.
2. something that is considered harmful, destructive, or evil.
Synonyms: pest, plague, CCP
|
|
|
|
|
Ah, write-only code. That makes me think of Forth.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
It brings APL to mind. AFAIK, the first write-only language by design.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Yes, that's a good example. Thankfully I have never had the misfortune of using it.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
One of my friends from high school taught himself to read it. He could also read brainf***. Useless talents, but talents nonetheless. It was quite impressive.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Daniel Pfeffer wrote: It brings APL to mind. AFAIK, the first write-only language by design. Actually, it was developed for blackboard use. Kenneth Iverson was teaching matrix math at Harvard, as an extension of the classical math operators, as a notation for math expressions involving matrices.
He was using it as a lecturing tool for several years, until someone at IBM suggested that just like a computer program could process plus and minus, it could handle matrix inversion and stuff like that - all those special symbols Iverson had been using on the letcuring hall blackboards.
APL is like user friendly Unix: Unix is user friendly - it is just somewhat picky in who its friends are.
|
|
|
|
|
For me all this goes (in a similar way) in the direction of dialects existing for natural languages. But for programming I prefer there is only one _defined_ language and no dialects ... more or less... of course now and then I also see the incentive of syntactic sugar. But it should stop at least after the first'?', what I remember in c# it is meanwhile '??'
[Edit]
Now and then I feel like we're moving back to assembler 'a?. (x => acc_A{...})'
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
Actually it makes a lot of sense. I use the comma operator in quite a few places.
|
|
|
|
|
Possibly why C# has altered the behavior of comma . (Sadly.)
|
|
|
|
|
The good ol' comma operator. Designed specifically to trap young players.
I grew up, many moons ago, in the era of 80 x 25 character screens for programming and so squeezing as much code as you could into as few lines as possible saved the ESCCtrl + F / B keys from wearing out. The ++/-- operators, dense conditionals in loops and single character variable names were what kept you productive (sorta).
Those days are long, long gone now. The comma operator now just gives me 'Nam flashbacks
cheers
Chris Maunder
|
|
|
|
|
The lowest price in my lifetime for oil was about $3/bbl - until today - when it dropped to $2/bbl, then below $1/bbl and finally went ing negative!
Normally, I'd delighted when oil prices drop - it save a lot of money for virtually everyone, both directly and in manufacturing costs. Apparently the "too much of a good thing" can really be bad.
Ultimately, a lot of the smaller producers will go under - and when all this straightens out, we may unfortunately see the $100-$150/bbl again as the OPEC-ish countries have their day.
Well, I didn't wish for this, but it certainly is a good example of "Be careful what you wish for".
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
It complements negative interest rates nicely.
|
|
|
|
|
I cannot help but wonder where it all will end?
Get me coffee and no one gets hurt!
|
|
|
|
|
"Oh Brave New World!"
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Momma!
Get me coffee and no one gets hurt!
|
|
|
|
|
We have seen similar situations with electric power generated from windmills in Denmark and Germany. When the working day is over, the need for electricity falls drastically i Middle Europe, but the windmills spin at the same speed. Nor can other kinds of power plants, like oil and more than any other: coal, easily be cranked up and down to adjust production to needs.
It turns out to be cheaper to pay Norway for accepting the excess electricity than alternative ways to regulate it. Besides, the Norwegian peak consumption is highest in early morning, before business life wakes up, and from late afternoon until midnight. This is because we are much more dependent on electric light and electric home heating that most other countries. Norway's hydroelectric turbines can be turned from zero maximum production (or vice versa) in not that many minutes. (It takes more time to switch the direction of those huge trans-ocean cables than it takes to adjust the production!)
So, during a few periods the last few years, Norway has been paid for covering peak demands mid-day, and been paid for handling the surplus power at night time. That's a fairly good deal. All it takes to copy that for the oil is to have storage space for a few billion barrels of oil. Or an immediate need for a few billion barrels, but that is less likely.
|
|
|
|